summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSam Parker <sam.parker@arm.com>2018-09-17 13:48:25 +0000
committerSam Parker <sam.parker@arm.com>2018-09-17 13:48:25 +0000
commit76d25d7f553dd49fe9696749383399200b07f7d5 (patch)
tree2fe2fb902b46a3541d73f01350c3228d838bcfd1 /llvm/lib
parentfb310c0af9f366454c61a4be18dc5aa791d23d0a (diff)
downloadbcm5719-llvm-76d25d7f553dd49fe9696749383399200b07f7d5.tar.gz
bcm5719-llvm-76d25d7f553dd49fe9696749383399200b07f7d5.zip
[ARM] Disallow icmp with negative imm and overflow
We allow overflowing instructions if they're decreasing and only used by an unsigned compare. Add the extra condition that the icmp cannot be using a negative immediate. Differential Revision: https://reviews.llvm.org/D52102 llvm-svn: 342392
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp b/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp
index e06f05a2d98..a1241b7a1e2 100644
--- a/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp
+++ b/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp
@@ -257,9 +257,20 @@ static bool isSafeOverflow(Instruction *I) {
return false;
auto *CI = cast<ICmpInst>(*I->user_begin());
+
+ // Don't support an icmp that deals with sign bits, including negative
+ // immediates
if (CI->isSigned())
return false;
+ if (auto *Const = dyn_cast<ConstantInt>(CI->getOperand(0)))
+ if (Const->isNegative())
+ return false;
+
+ if (auto *Const = dyn_cast<ConstantInt>(CI->getOperand(1)))
+ if (Const->isNegative())
+ return false;
+
bool NegImm = cast<ConstantInt>(I->getOperand(1))->isNegative();
bool IsDecreasing = ((Opc == Instruction::Sub) && !NegImm) ||
((Opc == Instruction::Add) && NegImm);
OpenPOWER on IntegriCloud