]> granicus.if.org Git - llvm/commitdiff
[X86] Don't peek through bitcasts before checking ISD::isBuildVectorOfConstantSDNodes...
authorCraig Topper <craig.topper@intel.com>
Thu, 28 Feb 2019 18:49:29 +0000 (18:49 +0000)
committerCraig Topper <craig.topper@intel.com>
Thu, 28 Feb 2019 18:49:29 +0000 (18:49 +0000)
We don't have any combines that can look through a bitcast to truncate a build vector of constants. So the truncate will stick around and give us something like this pattern (binop (trunc X), (trunc (bitcast (build_vector)))) which has two truncates in it. Which will be reversed by hoistLogicOpWithSameOpcodeHands in the generic DAG combiner. Thus causing an infinite loop.

Even if we had a combine for (truncate (bitcast (build_vector))), I think it would need to be implemented in getNode otherwise DAG combiner visit ordering would probably still visit the binop first and reverse it. Or combineTruncatedArithmetic would need to do its own constant folding.

Differential Revision: https://reviews.llvm.org/D58705

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

lib/Target/X86/X86ISelLowering.cpp

index 9b585846fa07647df62ae00e020a9c2e0a8244a3..ac49ba02351cc0966d43d8fc035cfacdfec654c3 100644 (file)
@@ -38717,8 +38717,11 @@ static SDValue combineTruncatedArithmetic(SDNode *N, SelectionDAG &DAG,
       return true;
 
     // See if this is a single use constant which can be constant folded.
-    SDValue BC = peekThroughOneUseBitcasts(Op);
-    return ISD::isBuildVectorOfConstantSDNodes(BC.getNode());
+    // NOTE: We don't peek throught bitcasts here because there is currently
+    // no support for constant folding truncate+bitcast+vector_of_constants. So
+    // we'll just send up with a truncate on both operands which will
+    // get turned back into (truncate (binop)) causing an infinite loop.
+    return ISD::isBuildVectorOfConstantSDNodes(Op.getNode());
   };
 
   auto TruncateArithmetic = [&](SDValue N0, SDValue N1) {