R600: Consider bitcast when folding const_address node.
authorTom Stellard <thomas.stellard@amd.com>
Thu, 31 Jan 2013 22:11:53 +0000 (22:11 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Thu, 31 Jan 2013 22:11:53 +0000 (22:11 +0000)
Patch by: Vincent Lejeune

Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174098 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/R600/AMDILISelDAGToDAG.cpp
lib/Target/R600/R600ISelLowering.cpp

index 567b3e26cf1486f33107becf7a5185a9947d92d0..ece26efceedf105b2ac2daa1386c935f0e666a84 100644 (file)
@@ -318,6 +318,9 @@ bool AMDGPUDAGToDAGISel::FoldOperands(unsigned Opcode,
       }
       }
       break;
+    case ISD::BITCAST:
+      Ops[OperandIdx[i] - 1] = Operand.getOperand(0);
+      return true;
     default:
       break;
     }
index 3dc5b0076e438094b4fd596c108e270cd66ad1bf..ff18a444245818e6a836ede9b24ca77284bd2fc8 100644 (file)
@@ -991,6 +991,14 @@ SDValue R600TargetLowering::PerformDAGCombine(SDNode *N,
         return Arg->getOperand(Element);
       }
     }
+    if (Arg.getOpcode() == ISD::BITCAST &&
+        Arg.getOperand(0).getOpcode() == ISD::BUILD_VECTOR) {
+      if (ConstantSDNode *Const = dyn_cast<ConstantSDNode>(N->getOperand(1))) {
+        unsigned Element = Const->getZExtValue();
+        return DAG.getNode(ISD::BITCAST, N->getDebugLoc(), N->getVTList(),
+            Arg->getOperand(0).getOperand(Element));
+      }
+    }
   }
   }
   return SDValue();