Be careful when looking through a vbit_convert. Optimizing this:
authorEvan Cheng <evan.cheng@apple.com>
Mon, 16 Oct 2006 22:49:37 +0000 (22:49 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Mon, 16 Oct 2006 22:49:37 +0000 (22:49 +0000)
(vector_shuffle
  (vbitconvert (vbuildvector (copyfromreg v4f32), 1, v4f32), 4, f32),
  (undef, undef, undef, undef), (0, 0, 0, 0), 4, f32)
to the
  vbitconvert
is a very bad idea.

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

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index ba90e23b04ed2f25871408e1c5e3ff371a3aa285..a27adba33b02e4a853b121aca410d711da85bc64 100644 (file)
@@ -3108,8 +3108,17 @@ SDOperand DAGCombiner::visitVVECTOR_SHUFFLE(SDNode *N) {
   // all scalar elements the same.
   if (isSplat) {
     SDNode *V = N0.Val;
-    if (V->getOpcode() == ISD::VBIT_CONVERT)
-      V = V->getOperand(0).Val;
+
+    // If this is a vbit convert that changes the element type of the vector but
+    // not the number of vector elements, look through it.  Be careful not to
+    // look though conversions that change things like v4f32 to v2f64.
+    if (V->getOpcode() == ISD::VBIT_CONVERT) {
+      SDOperand ConvInput = V->getOperand(0);
+      if (NumElts ==
+          ConvInput.getConstantOperandVal(ConvInput.getNumOperands()-2))
+        V = ConvInput.Val;
+    }
+
     if (V->getOpcode() == ISD::VBUILD_VECTOR) {
       unsigned NumElems = V->getNumOperands()-2;
       if (NumElems > BaseIdx) {