]> granicus.if.org Git - llvm/commitdiff
[DAGCombine] Fix (shl (ext (shl x, c1)), c2) -> (shl (ext x), (add c1, c2)) comment...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 19 Jun 2019 11:17:48 +0000 (11:17 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 19 Jun 2019 11:17:48 +0000 (11:17 +0000)
We pre-extend, not post.

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

lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/X86/combine-shl.ll

index 63f3df8f0ccd8d50800aab70e724e0248bf84ec9..ebb79ef9e481af2de89ee3582cc94c973ef7fff4 100644 (file)
@@ -7167,6 +7167,7 @@ SDValue DAGCombiner::visitSHL(SDNode *N) {
   if (DAG.MaskedValueIsZero(SDValue(N, 0),
                             APInt::getAllOnesValue(OpSizeInBits)))
     return DAG.getConstant(0, SDLoc(N), VT);
+
   // fold (shl x, (trunc (and y, c))) -> (shl x, (and (trunc y), (trunc c))).
   if (N1.getOpcode() == ISD::TRUNCATE &&
       N1.getOperand(0).getOpcode() == ISD::AND) {
@@ -7204,7 +7205,7 @@ SDValue DAGCombiner::visitSHL(SDNode *N) {
     }
   }
 
-  // fold (shl (ext (shl x, c1)), c2) -> (ext (shl x, (add c1, c2)))
+  // fold (shl (ext (shl x, c1)), c2) -> (shl (ext x), (add c1, c2))
   // For this to be valid, the second form must not preserve any of the bits
   // that are shifted out by the inner shift in the first form.  This means
   // the outer shift size must be >= the number of bits added by the ext.
index 3e54d29cef95de10c5683bb3a244f145377f05ff..8e84cfa25f295eb6434d54d2c199b898f362f629 100644 (file)
@@ -233,7 +233,7 @@ define <4 x i32> @combine_vec_shl_shl_zero1(<4 x i32> %x) {
   ret <4 x i32> %2
 }
 
-; fold (shl (ext (shl x, c1)), c2) -> (ext (shl x, (add c1, c2)))
+; fold (shl (ext (shl x, c1)), c2) -> (shl (ext x), (add c1, c2))
 define <8 x i32> @combine_vec_shl_ext_shl0(<8 x i16> %x) {
 ; SSE2-LABEL: combine_vec_shl_ext_shl0:
 ; SSE2:       # %bb.0: