diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2013-12-06 21:48:36 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2013-12-06 21:48:36 +0000 |
commit | ce5f93efd55285bf4ab1adcd9511973213e03982 (patch) | |
tree | 27ef2044480087ce965429ab65daa93cbf40ea97 /llvm/lib/Transforms | |
parent | 3dedae12b5453757055857e83a1f2624bf08d914 (diff) | |
download | bcm5719-llvm-ce5f93efd55285bf4ab1adcd9511973213e03982.tar.gz bcm5719-llvm-ce5f93efd55285bf4ab1adcd9511973213e03982.zip |
Don't use isNullValue to evaluate ConstantExpr
ConstantExpr can evaluate to false even when isNullValue gives false.
Fixes PR18143.
llvm-svn: 196611
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index 27f1a3eb699..191a101e0a3 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/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), |