aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-08 19:28:47 +0000
committerChris Lattner <sabre@nondot.org>2010-01-08 19:28:47 +0000
commitc8b3fce5c5f0785b05df9cf93772a67f56bc3640 (patch)
treec5b4efb8f545dad7d8100ba17b7c7479dad6b304 /lib/Transforms
parent14bf8f028587cea01b59d508885b6220850e9d4e (diff)
downloadexternal_llvm-c8b3fce5c5f0785b05df9cf93772a67f56bc3640.zip
external_llvm-c8b3fce5c5f0785b05df9cf93772a67f56bc3640.tar.gz
external_llvm-c8b3fce5c5f0785b05df9cf93772a67f56bc3640.tar.bz2
mplement a theoretical fixme.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93024 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/InstCombine/InstCombineCasts.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCasts.cpp b/lib/Transforms/InstCombine/InstCombineCasts.cpp
index a1d6d29..be18311 100644
--- a/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -476,9 +476,13 @@ static unsigned CanEvaluateSExtd(Value *V, const Type *Ty,
/// insert the code to evaluate the expression.
Value *InstCombiner::EvaluateInDifferentType(Value *V, const Type *Ty,
bool isSigned) {
- // FIXME: use libanalysis constant folding.
- if (Constant *C = dyn_cast<Constant>(V))
- return ConstantExpr::getIntegerCast(C, Ty, isSigned /*Sext or ZExt*/);
+ if (Constant *C = dyn_cast<Constant>(V)) {
+ C = ConstantExpr::getIntegerCast(C, Ty, isSigned /*Sext or ZExt*/);
+ // If we got a constantexpr back, try to simplify it with TD info.
+ if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
+ C = ConstantFoldConstantExpression(CE, TD);
+ return C;
+ }
// Otherwise, it must be an instruction.
Instruction *I = cast<Instruction>(V);