[X86][AVX] SimplifyDemandedBitsForTargetNode - add basic X86ISD::VBROADCAST handling.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 26 Feb 2021 16:12:59 +0000 (16:12 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 26 Feb 2021 16:13:14 +0000 (16:13 +0000)
Simplify through to the scalar/vector source operand.

llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll

index 86a4190..dd0ce22 100644 (file)
@@ -38908,6 +38908,16 @@ bool X86TargetLowering::SimplifyDemandedBitsForTargetNode(
     }
     // TODO - add general PACKSS/PACKUS SimplifyDemandedBits support.
     break;
+  case X86ISD::VBROADCAST: {
+    SDValue Src = Op.getOperand(0);
+    MVT SrcVT = Src.getSimpleValueType();
+    APInt DemandedElts = APInt::getOneBitSet(
+        SrcVT.isVector() ? SrcVT.getVectorNumElements() : 1, 0);
+    if (SimplifyDemandedBits(Src, OriginalDemandedBits, DemandedElts, Known,
+                             TLO, Depth + 1))
+      return true;
+    break;
+  }
   case X86ISD::PCMPGT:
     // icmp sgt(0, R) == ashr(R, BitWidth-1).
     // iff we only need the sign bit then we can use R directly.
index da169b6..7187425 100644 (file)
@@ -781,10 +781,9 @@ define <32 x i8> @constant_fold_pshufb_256() {
 define i32 @broadcast_v2i64_multiuse(i64* %p0) {
 ; X86-LABEL: broadcast_v2i64_multiuse:
 ; X86:       # %bb.0: # %entry
-; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
-; X86-NEXT:    vmovq {{.*#+}} xmm0 = mem[0],zero
-; X86-NEXT:    vmovd %xmm0, %eax
-; X86-NEXT:    addl (%ecx), %eax
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    movl (%eax), %eax
+; X86-NEXT:    addl %eax, %eax
 ; X86-NEXT:    retl
 ;
 ; X64-LABEL: broadcast_v2i64_multiuse: