summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-11-18 22:06:45 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-11-18 22:06:45 +0000
commitc6b8e20a5c59d8635ecf7141e700dafae782602e (patch)
tree9d8154a5c5ba5095ee6229301002792ab7c58c76 /llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
parentef202d96c79f4a3c3f0ed15de073be9a012de92e (diff)
downloadbcm5719-llvm-c6b8e20a5c59d8635ecf7141e700dafae782602e.tar.gz
bcm5719-llvm-c6b8e20a5c59d8635ecf7141e700dafae782602e.zip
InstCombine: Fix another infinite loop caused by visitFPTrunc
We would attempt to replace an frem's operand with the same operand. This would cause InstCombine to think real work was done, causing InstCombine to enter an infinite loop. This fixes the second part of PR21576. llvm-svn: 222265
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index a0570f7ebd4..aba77bb4462 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1269,13 +1269,12 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) {
// type of OpI doesn't enter into things at all. We simply evaluate
// in whichever source type is larger, then convert to the
// destination type.
- Value *NewLHS = LHSOrig, *NewRHS = RHSOrig;
if (LHSWidth < SrcWidth)
- NewLHS = Builder->CreateFPExt(NewLHS, RHSOrig->getType());
+ LHSOrig = Builder->CreateFPExt(LHSOrig, RHSOrig->getType());
else if (RHSWidth <= SrcWidth)
- NewRHS = Builder->CreateFPExt(NewRHS, LHSOrig->getType());
- if (NewLHS != LHSOrig || NewRHS != RHSOrig) {
- Value *ExactResult = Builder->CreateFRem(NewLHS, NewRHS);
+ RHSOrig = Builder->CreateFPExt(RHSOrig, LHSOrig->getType());
+ if (LHSOrig != OpI->getOperand(0) || RHSOrig != OpI->getOperand(1)) {
+ Value *ExactResult = Builder->CreateFRem(LHSOrig, RHSOrig);
if (Instruction *RI = dyn_cast<Instruction>(ExactResult))
RI->copyFastMathFlags(OpI);
return CastInst::CreateFPCast(ExactResult, CI.getType());
OpenPOWER on IntegriCloud