Index: lib/Transforms/Scalar/SCCP.cpp =================================================================== --- lib/Transforms/Scalar/SCCP.cpp +++ lib/Transforms/Scalar/SCCP.cpp @@ -473,6 +473,7 @@ void visitTerminatorInst(TerminatorInst &TI); void visitCastInst(CastInst &I); + void visitBitCastInst(BitCastInst &I); void visitSelectInst(SelectInst &I); void visitBinaryOperator(Instruction &I); void visitCmpInst(CmpInst &I); @@ -769,6 +770,22 @@ } } +void SCCPSolver::visitBitCastInst(BitCastInst &I) { + for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) { + LatticeVal OpSt = getValueState(I.getOperand(i)); + if (OpSt.isOverdefined()) + return markOverdefined(&I); + if (OpSt.isUndefined()) + return; // Operands are not resolved yet. + } + /* All the operands are known to be constant */ + Constant *C = ConstantFoldCastOperand(I.getOpcode(), + getValueState(I.getOperand(0)).getConstant(), + I.getType(), DL); + if (isa(C)) + return; + markConstant(&I, C); +} void SCCPSolver::visitExtractValueInst(ExtractValueInst &EVI) { // If this returns a struct, mark all elements over defined, we don't track Index: test/Transforms/SCCP/bitcast.ll =================================================================== --- /dev/null +++ test/Transforms/SCCP/bitcast.ll @@ -0,0 +1,9 @@ +; RUN: opt < %s -ipsccp -S | FileCheck %s + +define i128 @vector_to_int_cast() { + %A = bitcast <4 x i32> to i128 + ret i128 %A +} + +; CHECK: define i128 @vector_to_int_cast( +; CHECK-NEXT: ret i128 85070591750041656499021422275829170176