]> granicus.if.org Git - llvm/commitdiff
[x86] fold shuffles of h-ops that have an undef operand
authorSanjay Patel <spatel@rotateright.com>
Wed, 3 Apr 2019 22:40:35 +0000 (22:40 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 3 Apr 2019 22:40:35 +0000 (22:40 +0000)
If an operand is undef, we can assume it's the same as the
other operand.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357644 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/haddsub-shuf.ll

index 84009979ea172f918169fe135acc4f50281b598e..a05fd557ca2d79253cab434a858f4e8bc916d775 100644 (file)
@@ -32880,8 +32880,8 @@ static SDValue foldShuffleOfHorizOp(SDNode *N) {
   // lanes of each operand as:
   // v4X32: A[0] + A[1] , A[2] + A[3] , B[0] + B[1] , B[2] + B[3]
   // ...similarly for v2f64 and v8i16.
-  // TODO: Handle UNDEF operands.
-  if (HOp.getOperand(0) != HOp.getOperand(1))
+  if (!HOp.getOperand(0).isUndef() && !HOp.getOperand(1).isUndef() &&
+      HOp.getOperand(0) != HOp.getOperand(1))
     return SDValue();
 
   // When the operands of a horizontal math op are identical, the low half of
index e50d6af6e09404c48ce175bdcdb216c4cd17a340..c37e9862ed70217d7f71f1487f44bf4555ff812a 100644 (file)
@@ -381,7 +381,6 @@ define <4 x double> @hadd_v4f64_scalar_splat(<4 x double> %a) {
 ; AVX-LABEL: hadd_v4f64_scalar_splat:
 ; AVX:       # %bb.0:
 ; AVX-NEXT:    vhaddpd %ymm0, %ymm0, %ymm0
-; AVX-NEXT:    vmovddup {{.*#+}} ymm0 = ymm0[0,0,2,2]
 ; AVX-NEXT:    retq
   %a0 = extractelement <4 x double> %a, i32 0
   %a1 = extractelement <4 x double> %a, i32 1