mplement a theoretical fixme.
authorChris Lattner <sabre@nondot.org>
Fri, 8 Jan 2010 19:28:47 +0000 (19:28 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 8 Jan 2010 19:28:47 +0000 (19:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93024 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineCasts.cpp

index a1d6d29ecd420ab4fab8c4770713c563948c0fb7..be18311846c7342e7fcc01ebc2643af97abc5617 100644 (file)
@@ -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);