Fix a case where constantexprs could leak into the PPC isel.
llvm-svn: 15661
diff --git a/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp b/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp
index 8fd947f..96067f6 100644
--- a/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp
+++ b/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp
@@ -1260,7 +1260,10 @@
if (Val) {
if (Constant *C = dyn_cast<Constant>(Val)) {
Val = ConstantExpr::getCast(C, Type::IntTy);
- Ty = Type::IntTy;
+ if (isa<ConstantExpr>(Val)) // Could not fold
+ Val = C;
+ else
+ Ty = Type::IntTy; // Folded!
}
// If this is a simple constant, just emit a load directly to avoid the copy