From d555bde59fd05819a2154255c798ead4d35e622a Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Fri, 8 Jul 2016 19:13:40 +0000 Subject: [SCCP] Fold constants as we build them whne visiting cast instructions. This should be slightly more efficient and could avoid spurious overdefined markings, as Eli pointed out. Differential Revision: http://reviews.llvm.org/D22122 llvm-svn: 274905 --- llvm/lib/Transforms/Scalar/SCCP.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index d4c156e994c..adc70d917f5 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/lib/Transforms/Scalar/SCCP.cpp @@ -760,8 +760,10 @@ void SCCPSolver::visitCastInst(CastInst &I) { if (OpSt.isOverdefined()) // Inherit overdefinedness of operand markOverdefined(&I); else if (OpSt.isConstant()) { - Constant *C = - ConstantExpr::getCast(I.getOpcode(), OpSt.getConstant(), I.getType()); + // Fold the constant as we build. + Constant *C = ConstantFoldCastOperand( + I.getOpcode(), getValueState(I.getOperand(0)).getConstant(), + I.getType(), DL); if (isa(C)) return; // Propagate constant value -- cgit v1.2.3