summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2016-07-08 19:13:40 +0000
committerDavide Italiano <davide@freebsd.org>2016-07-08 19:13:40 +0000
commitd555bde59fd05819a2154255c798ead4d35e622a (patch)
tree476262bef25bca543c1c6b8cb9834a5510c68153 /llvm/lib/Transforms
parentdca9bffa315a4f4b80815af5e15119ac1d122216 (diff)
downloadbcm5719-llvm-d555bde59fd05819a2154255c798ead4d35e622a.tar.gz
bcm5719-llvm-d555bde59fd05819a2154255c798ead4d35e622a.zip
[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
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/SCCP.cpp6
1 files changed, 4 insertions, 2 deletions
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<UndefValue>(C))
return;
// Propagate constant value
OpenPOWER on IntegriCloud