[llvm] r333804 - [X86] Do something sensible when an expand load intrinsic is passed a 0 mask.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 1 15:59:08 PDT 2018


Author: ctopper
Date: Fri Jun  1 15:59:07 2018
New Revision: 333804

URL: http://llvm.org/viewvc/llvm-project?rev=333804&view=rev
Log:
[X86] Do something sensible when an expand load intrinsic is passed a 0 mask.

Previously we just returned undef, but really we should be returning the pass thru input. We also need to make sure we preserve the chain output that the original intrinsic node had to maintain connectivity in the DAG. So we should just return the incoming chain as the output chain.

Modified:
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
    llvm/trunk/test/CodeGen/X86/avx512-intrinsics.ll

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=333804&r1=333803&r2=333804&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Jun  1 15:59:07 2018
@@ -21641,7 +21641,7 @@ static SDValue LowerINTRINSIC_W_CHAIN(SD
     if (isAllOnesConstant(Mask)) // Return a regular (unmasked) vector load.
       return DAG.getLoad(VT, dl, Chain, Addr, MemIntr->getMemOperand());
     if (X86::isZeroNode(Mask))
-      return DAG.getUNDEF(VT);
+      return DAG.getMergeValues({PassThru, Chain}, dl);
 
     MVT MaskVT = MVT::getVectorVT(MVT::i1, VT.getVectorNumElements());
     SDValue VMask = getMaskNode(Mask, MaskVT, Subtarget, DAG, dl);

Modified: llvm/trunk/test/CodeGen/X86/avx512-intrinsics.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avx512-intrinsics.ll?rev=333804&r1=333803&r2=333804&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/avx512-intrinsics.ll (original)
+++ llvm/trunk/test/CodeGen/X86/avx512-intrinsics.ll Fri Jun  1 15:59:07 2018
@@ -280,6 +280,15 @@ define <8 x double> @test_expand_load_pd
   ret <8 x double> %res
 }
 
+; Make sure we don't crash if you pass 0 to the mask.
+define <8 x double> @test_zero_mask_expand_load_pd_512(i8* %addr, <8 x double> %data, i8 %mask) {
+; CHECK-LABEL: test_zero_mask_expand_load_pd_512:
+; CHECK:       ## %bb.0:
+; CHECK-NEXT:    retq
+  %res = call <8 x double> @llvm.x86.avx512.mask.expand.load.pd.512(i8* %addr, <8 x double> %data, i8 0)
+  ret <8 x double> %res
+}
+
 define <16 x float> @test_mask_expand_load_ps_512(i8* %addr, <16 x float> %data, i16 %mask) {
 ; CHECK-LABEL: test_mask_expand_load_ps_512:
 ; CHECK:       ## %bb.0:




More information about the llvm-commits mailing list