[PATCH] D41643: [DAG] Fix for Bug PR34620 - Allow SimplifyDemandedBits to look through bitcasted constants

Sam Conrad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 1 14:39:46 PST 2018


sameconrad updated this revision to Diff 128395.
sameconrad added a comment.

Updated to remove isConstOrConstSplat condition


https://reviews.llvm.org/D41643

Files:
  lib/CodeGen/SelectionDAG/TargetLowering.cpp
  test/CodeGen/X86/combine-and.ll


Index: test/CodeGen/X86/combine-and.ll
===================================================================
--- test/CodeGen/X86/combine-and.ll
+++ test/CodeGen/X86/combine-and.ll
@@ -275,13 +275,12 @@
 ; SimplifyDemandedBits
 ;
 
-; PR34620 - redundant PAND after vector shift of a byte vector (PSRLW)
+; Redundant pand generated by lowering lshr <16xi8> is eliminated
 define <16 x i8> @PR34620(<16 x i8> %a0, <16 x i8> %a1) {
 ; CHECK-LABEL: PR34620:
 ; CHECK:       # %bb.0:
 ; CHECK-NEXT:    psrlw $1, %xmm0
 ; CHECK-NEXT:    pand {{.*}}(%rip), %xmm0
-; CHECK-NEXT:    pand {{.*}}(%rip), %xmm0
 ; CHECK-NEXT:    paddb %xmm1, %xmm0
 ; CHECK-NEXT:    retq
   %1 = lshr <16 x i8> %a0, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
Index: lib/CodeGen/SelectionDAG/TargetLowering.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -1220,6 +1220,12 @@
                                                  Sign, ShAmt));
       }
     }
+    // If this is a bitcast, let computeKnownBits handle it.  Only do this on a
+    // recursive call where Known may be useful to the caller.
+    if (Depth > 0) {
+      TLO.DAG.computeKnownBits(Op, Known, Depth);
+      return false;
+    }
     break;
   case ISD::ADD:
   case ISD::MUL:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41643.128395.patch
Type: text/x-patch
Size: 1396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180101/70e72c2c/attachment.bin>


More information about the llvm-commits mailing list