From: Ben Crocker Date: Thu, 28 Sep 2017 18:09:12 +0000 (-0400) Subject: gallivm/ppc64le: adjust VSX code generation control. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e93f056a4e5babde516c9ef53ae3547f68f1b824;p=mesa.git gallivm/ppc64le: adjust VSX code generation control. In lp_build_create_jit_compiler_for_module(), advance the minimum version of LLVM for VSX code generation to 4.0; this is the minimum revision at which several known VSX code generation bugs are fixed: https://llvm.org/bugs/show_bug.cgi?id=25503 (fixed in 3.8.1) https://llvm.org/bugs/show_bug.cgi?id=26775 (fixed in 3.8.1) https://llvm.org/bugs/show_bug.cgi?id=33531 (fixed in 4.0) An llc performance bug introduced in LLVM 4.0, https://llvm.org/bugs/show_bug.cgi?id=34647 is still pending as of LLVM 5.0, but only has a pronounced effect on one of the Piglit tests: ext_transform_feedback-max-varyings. All changes tested via Piglit. Cc: "17.2" Signed-off-by: Ben Crocker Acked-by: Roland Scheidegger --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index 60d88269e50..d988910a7eb 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -630,23 +630,46 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, #if defined(PIPE_ARCH_PPC) MAttrs.push_back(util_cpu_caps.has_altivec ? "+altivec" : "-altivec"); #if (HAVE_LLVM >= 0x0304) -#if (HAVE_LLVM <= 0x0307) || (HAVE_LLVM == 0x0308 && MESA_LLVM_VERSION_PATCH == 0) +#if (HAVE_LLVM < 0x0400) /* * Make sure VSX instructions are disabled - * See LLVM bug https://llvm.org/bugs/show_bug.cgi?id=25503#c7 + * See LLVM bugs: + * https://llvm.org/bugs/show_bug.cgi?id=25503#c7 (fixed in 3.8.1) + * https://llvm.org/bugs/show_bug.cgi?id=26775 (fixed in 3.8.1) + * https://llvm.org/bugs/show_bug.cgi?id=33531 (fixed in 4.0) + * https://llvm.org/bugs/show_bug.cgi?id=34647 (llc performance on certain unusual shader IR; intro'd in 4.0, pending as of 5.0) */ if (util_cpu_caps.has_altivec) { MAttrs.push_back("-vsx"); } #else /* - * However, bug 25503 is fixed, by the same fix that fixed - * bug 26775, in versions of LLVM later than 3.8 (starting with 3.8.1): - * Make sure VSX instructions are ENABLED - * See LLVM bug https://llvm.org/bugs/show_bug.cgi?id=26775 + * Bug 25503 is fixed, by the same fix that fixed + * bug 26775, in versions of LLVM later than 3.8 (starting with 3.8.1). + * BZ 33531 actually comprises more than one bug, all of + * which are fixed in LLVM 4.0. + * + * With LLVM 4.0 or higher: + * Make sure VSX instructions are ENABLED, unless + * a) the entire -mattr option is overridden via GALLIVM_MATTRS, or + * b) VSX instructions are explicitly enabled/disabled via GALLIVM_VSX=1 or 0. */ if (util_cpu_caps.has_altivec) { - MAttrs.push_back("+vsx"); + char *env_mattrs = getenv("GALLIVM_MATTRS"); + if (env_mattrs) { + MAttrs.push_back(env_mattrs); + } + else { + boolean enable_vsx = true; + char *env_vsx = getenv("GALLIVM_VSX"); + if (env_vsx && env_vsx[0] == '0') { + enable_vsx = false; + } + if (enable_vsx) + MAttrs.push_back("+vsx"); + else + MAttrs.push_back("-vsx"); + } } #endif #endif