summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorTom Stellard <tstellar@redhat.com>2020-05-09 00:34:05 +0000
committerTom Stellard <tstellar@redhat.com>2020-06-23 18:45:59 -0700
commitbe4501f6e487fc27b242e0799cfeed3b4eedc4cd (patch)
tree3503f839ef829602339d4fa290c4e13ea4a90eda /llvm/lib
parent28a6713e107c9f878cb6c59db8548bb732dcc79d (diff)
downloadbcm5719-llvm-be4501f6e487fc27b242e0799cfeed3b4eedc4cd.tar.gz
bcm5719-llvm-be4501f6e487fc27b242e0799cfeed3b4eedc4cd.zip
[InstCombine] prevent infinite loop with sub/abs of constant expression
PR45539: https://bugs.llvm.org/show_bug.cgi?id=45539 (cherry picked from commit 01bcc3e9371470e1974f066ced353df15e10056d)
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index ec976a971e3..23561c25c50 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -1768,7 +1768,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
Constant *C2;
// C-(C2-X) --> X+(C-C2)
- if (match(Op1, m_Sub(m_Constant(C2), m_Value(X))))
+ if (match(Op1, m_Sub(m_Constant(C2), m_Value(X))) && !isa<ConstantExpr>(C2))
return BinaryOperator::CreateAdd(X, ConstantExpr::getSub(C, C2));
// C-(X+C2) --> (C-C2)-X
OpenPOWER on IntegriCloud