aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-31 19:05:27 +0000
committerChris Lattner <sabre@nondot.org>2009-01-31 19:05:27 +0000
commit39c27eddc536578d1694f8e0cf81ae9a6bf9da51 (patch)
tree8f5aa93e526d17eccd929a97664312a19cbcd3fe /lib/Transforms
parent92abc62399881ba9c525be80362c134ad836e2d9 (diff)
downloadexternal_llvm-39c27eddc536578d1694f8e0cf81ae9a6bf9da51.zip
external_llvm-39c27eddc536578d1694f8e0cf81ae9a6bf9da51.tar.gz
external_llvm-39c27eddc536578d1694f8e0cf81ae9a6bf9da51.tar.bz2
Fix PR3452 (an infinite loop bootstrapping) by disabling the recent
improvements to the EvaluateInDifferentType code. This code works by just inserted a bunch of new code and then seeing if it is useful. Instcombine is not allowed to do this: it can only insert new code if it is useful, and only when it is converging to a more canonical fixed point. Now that we iterate when DCE makes progress, this causes an infinite loop when the code ends up not being used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63483 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 2b0e0d1..8b9c599 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -7892,15 +7892,15 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) {
break;
case Instruction::ZExt: {
DoXForm = NumCastsRemoved >= 1;
- if (!DoXForm) {
+ if (!DoXForm && 0) {
// If it's unnecessary to issue an AND to clear the high bits, it's
// always profitable to do this xform.
- Value *TryRes = EvaluateInDifferentType(SrcI, DestTy,
- CI.getOpcode() == Instruction::SExt);
+ Value *TryRes = EvaluateInDifferentType(SrcI, DestTy, false);
APInt Mask(APInt::getBitsSet(DestBitSize, SrcBitSize, DestBitSize));
if (MaskedValueIsZero(TryRes, Mask))
return ReplaceInstUsesWith(CI, TryRes);
- else if (Instruction *TryI = dyn_cast<Instruction>(TryRes))
+
+ if (Instruction *TryI = dyn_cast<Instruction>(TryRes))
if (TryI->use_empty())
EraseInstFromFunction(*TryI);
}
@@ -7908,7 +7908,7 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) {
}
case Instruction::SExt: {
DoXForm = NumCastsRemoved >= 2;
- if (!DoXForm && !isa<TruncInst>(SrcI)) {
+ if (!DoXForm && !isa<TruncInst>(SrcI) && 0) {
// If we do not have to emit the truncate + sext pair, then it's always
// profitable to do this xform.
//
@@ -7918,12 +7918,12 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) {
// t3 = sext i16 t2 to i32
// !=
// i32 t1
- Value *TryRes = EvaluateInDifferentType(SrcI, DestTy,
- CI.getOpcode() == Instruction::SExt);
+ Value *TryRes = EvaluateInDifferentType(SrcI, DestTy, true);
unsigned NumSignBits = ComputeNumSignBits(TryRes);
if (NumSignBits > (DestBitSize - SrcBitSize))
return ReplaceInstUsesWith(CI, TryRes);
- else if (Instruction *TryI = dyn_cast<Instruction>(TryRes))
+
+ if (Instruction *TryI = dyn_cast<Instruction>(TryRes))
if (TryI->use_empty())
EraseInstFromFunction(*TryI);
}
@@ -7932,11 +7932,13 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) {
}
if (DoXForm) {
+ DOUT << "ICE: EvaluateInDifferentType converting expression type to avoid"
+ << " cast: " << CI;
Value *Res = EvaluateInDifferentType(SrcI, DestTy,
CI.getOpcode() == Instruction::SExt);
if (JustReplace)
- // Just replace this cast with the result.
- return ReplaceInstUsesWith(CI, Res);
+ // Just replace this cast with the result.
+ return ReplaceInstUsesWith(CI, Res);
assert(Res->getType() == DestTy);
switch (CI.getOpcode()) {