summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-07-10 17:13:27 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-07-10 17:13:27 +0000
commit04934b0feca39e7d7818aa8d9b312c53e78f9785 (patch)
tree86d8613c2a21c3b494ef1f9c1e46bed9c0f5382b /llvm/lib
parentc1f152ee6c5163cd19a4f695bbb4321da2a0149b (diff)
downloadbcm5719-llvm-04934b0feca39e7d7818aa8d9b312c53e78f9785.tar.gz
bcm5719-llvm-04934b0feca39e7d7818aa8d9b312c53e78f9785.zip
InstCombine: Fix a crash in Descale for multiply-by-zero
Fix a crash in `InstCombiner::Descale()` when a multiply-by-zero gets created as an argument to a GEP partway through an iteration, causing -instcombine to optimize the GEP before the multiply. rdar://problem/17615671 llvm-svn: 212742
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstructionCombining.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 46e3bfc7e44..08e24461a61 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1120,6 +1120,12 @@ Value *InstCombiner::Descale(Value *Val, APInt Scale, bool &NoSignedWrap) {
return nullptr;
}
+ // If Op is zero then Val = Op * Scale.
+ if (match(Op, m_Zero())) {
+ NoSignedWrap = true;
+ return Op;
+ }
+
// We know that we can successfully descale, so from here on we can safely
// modify the IR. Op holds the descaled version of the deepest term in the
// expression. NoSignedWrap is 'true' if multiplying Op by Scale is known
OpenPOWER on IntegriCloud