summaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2013-12-06 21:48:36 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2013-12-06 21:48:36 +0000
commit42883d0ac4388c12c856225760fe591a361db7bc (patch)
treed1b34bcd6a84136d12e6b42efe7c8df97b76dc59 /lib/Transforms/InstCombine
parent92b10e5f858b5554a569007eeaf7a48bad622aea (diff)
downloadllvm-42883d0ac4388c12c856225760fe591a361db7bc.tar.gz
llvm-42883d0ac4388c12c856225760fe591a361db7bc.tar.bz2
llvm-42883d0ac4388c12c856225760fe591a361db7bc.tar.xz
Don't use isNullValue to evaluate ConstantExpr
ConstantExpr can evaluate to false even when isNullValue gives false. Fixes PR18143. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196611 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine')
-rw-r--r--lib/Transforms/InstCombine/InstructionCombining.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp
index 27f1a3eb69..191a101e0a 100644
--- a/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -699,7 +699,10 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) {
Value *TrueVInPred = TrueV->DoPHITranslation(PhiTransBB, ThisBB);
Value *FalseVInPred = FalseV->DoPHITranslation(PhiTransBB, ThisBB);
Value *InV = 0;
- if (Constant *InC = dyn_cast<Constant>(PN->getIncomingValue(i)))
+ // Beware of ConstantExpr: it may eventually evaluate to getNullValue,
+ // even if currently isNullValue gives false.
+ Constant *InC = dyn_cast<Constant>(PN->getIncomingValue(i));
+ if (InC && !isa<ConstantExpr>(InC))
InV = InC->isNullValue() ? FalseVInPred : TrueVInPred;
else
InV = Builder->CreateSelect(PN->getIncomingValue(i),