Am 17.04.2016 um 11:06 schrieb Jose Fonseca: > On 16/04/16 22:30, srol...@vmware.com wrote: >> From: Roland Scheidegger <srol...@vmware.com> >> >> llvm 3.7 sometimes simply miscompiles vector selects. > > Reviewed-by: Jose Fonseca <jfons...@vmware.com> > >> See https://bugs.freedesktop.org/show_bug.cgi?id=94972 > > Great detective work. > > I think you should make a LLVM test case out of the IR on that bug and > propose on llvm-commits, to guarantee it won't regress again. See > test/CodeGen/X86/vselect-avx.ll for example.
After some more digging, there actually IS already a test for this (pretty much exactly the same as mine). It was in 3.7 as well - of course not very helpful with the wrong expected result... This fixed it: commit 30ead638b8b7ad4d70d25ef3c70f0d6b21522784 Author: Michael Kuperstein <michael.m.kuperst...@intel.com> Date: Thu Oct 8 08:13:02 2015 +0000 [X86] Fix wrong treatment of multi-lane blends in BUILD_VECTORtoBlendMask() This fixes two separate bugs: 1) The mask for the high lane was not set correctly. That fixes PR24532. 2) The transformation should bail out if it believes it involves more than 2 lanes, as it does not currently do anything sensible in this case. Differential Revision: http://reviews.llvm.org/D13505 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249669 91177308-0d34-0410-b5e6-96231b3b80d8 Roland > > Jose > >> --- >> src/gallium/auxiliary/gallivm/lp_bld_logic.c | 8 +++++--- >> 1 file changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.c >> b/src/gallium/auxiliary/gallivm/lp_bld_logic.c >> index 91f316c..620aece 100644 >> --- a/src/gallium/auxiliary/gallivm/lp_bld_logic.c >> +++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.c >> @@ -315,14 +315,16 @@ lp_build_select(struct lp_build_context *bld, >> mask = LLVMBuildTrunc(builder, mask, >> LLVMInt1TypeInContext(lc), ""); >> res = LLVMBuildSelect(builder, mask, a, b, ""); >> } >> - else if (LLVMIsConstant(mask) || >> - LLVMGetInstructionOpcode(mask) == LLVMSExt) { >> + else if (!(HAVE_LLVM == 0x0307) && >> + (LLVMIsConstant(mask) || >> + LLVMGetInstructionOpcode(mask) == LLVMSExt)) { >> /* Generate a vector select. >> * >> * Using vector selects should avoid emitting intrinsics hence >> avoid >> - * hidering optimization passes, but vector selects weren't >> properly >> + * hindering optimization passes, but vector selects weren't >> properly >> * supported yet for a long time, and LLVM will generate poor >> code when >> * the mask is not the result of a comparison. >> + * Also, llvm 3.7 may miscompile them (bug 94972). >> */ >> >> /* Convert the mask to a vector of booleans. >> > > > > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev