summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2019-03-14 23:14:31 +0000
committerSanjay Patel <spatel@rotateright.com>2019-03-14 23:14:31 +0000
commit2c9275a79008807a5791d3fd0002887f329c5ac6 (patch)
tree72f9b2661c22c181ddb58d09fae1147678c01da2 /llvm/lib/CodeGen
parent96c1f2cd6c82de9816a0b7a1c1e1b2ea1caea4bc (diff)
downloadbcm5719-llvm-2c9275a79008807a5791d3fd0002887f329c5ac6.tar.gz
bcm5719-llvm-2c9275a79008807a5791d3fd0002887f329c5ac6.zip
[CGP] add another bailout for degenerate code (PR41064)
This is almost the same as: rL355345 ...and should prevent any potential crashing from examples like: https://bugs.llvm.org/show_bug.cgi?id=41064 ...although the bug was masked by: rL355823 ...and I'm not sure how to repro the problem after that change. llvm-svn: 356218
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index e70e4ee0308..e8498eb375e 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -1267,8 +1267,12 @@ static bool combineToUAddWithOverflow(CmpInst *Cmp, const TargetLowering &TLI,
static bool combineToUSubWithOverflow(CmpInst *Cmp, const TargetLowering &TLI,
const DataLayout &DL, DominatorTree &DT,
bool &ModifiedDT) {
- // Convert (A u> B) to (A u< B) to simplify pattern matching.
+ // We are not expecting non-canonical/degenerate code. Just bail out.
Value *A = Cmp->getOperand(0), *B = Cmp->getOperand(1);
+ if (isa<Constant>(A) && isa<Constant>(B))
+ return false;
+
+ // Convert (A u> B) to (A u< B) to simplify pattern matching.
ICmpInst::Predicate Pred = Cmp->getPredicate();
if (Pred == ICmpInst::ICMP_UGT) {
std::swap(A, B);
OpenPOWER on IntegriCloud