summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM
diff options
context:
space:
mode:
authorSam Parker <sam.parker@arm.com>2019-02-21 09:33:18 +0000
committerSam Parker <sam.parker@arm.com>2019-02-21 09:33:18 +0000
commit6ed47bee2757213acd064bb466b4c84b490ed1a8 (patch)
tree98d7b01a068e6bf417b10b589612bf78f995f35f /llvm/lib/Target/ARM
parent0e98ad264551e6bae1c919be68a6de794f2b6355 (diff)
downloadbcm5719-llvm-6ed47bee2757213acd064bb466b4c84b490ed1a8.tar.gz
bcm5719-llvm-6ed47bee2757213acd064bb466b4c84b490ed1a8.zip
[ARM] Negative constants mishandled in ARM CGP
During type promotion, sometimes we convert negative an add with a negative constant into a sub with a positive constant. The loop that performs this transformation has two issues: - it iterates over a set, causing non-determinism. - it breaks, instead of continuing, when it finds the first non-negative operand. Differential Revision: https://reviews.llvm.org/D58452 llvm-svn: 354557
Diffstat (limited to 'llvm/lib/Target/ARM')
-rw-r--r--llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp b/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp
index e9f5e6a4201..b59f05d7112 100644
--- a/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp
+++ b/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp
@@ -119,7 +119,7 @@ class IRPromoter {
// This defines the max range of the values that we allow in the promoted
// tree.
IntegerType *OrigTy = nullptr;
- SmallPtrSetImpl<Value*> *Visited;
+ SetVector<Value*> *Visited;
SmallPtrSetImpl<Value*> *Sources;
SmallPtrSetImpl<Instruction*> *Sinks;
SmallPtrSetImpl<Instruction*> *SafeToPromote;
@@ -138,7 +138,7 @@ public:
void Mutate(Type *OrigTy,
- SmallPtrSetImpl<Value*> &Visited,
+ SetVector<Value*> &Visited,
SmallPtrSetImpl<Value*> &Sources,
SmallPtrSetImpl<Instruction*> &Sinks,
SmallPtrSetImpl<Instruction*> &SafeToPromote);
@@ -498,7 +498,7 @@ void IRPromoter::PrepareConstants() {
if (auto *Const = dyn_cast<ConstantInt>(I->getOperand(1))) {
if (!Const->isNegative())
- break;
+ continue;
unsigned Opc = I->getOpcode();
if (Opc != Instruction::Add && Opc != Instruction::Sub)
@@ -755,7 +755,7 @@ void IRPromoter::ConvertTruncs() {
}
void IRPromoter::Mutate(Type *OrigTy,
- SmallPtrSetImpl<Value*> &Visited,
+ SetVector<Value*> &Visited,
SmallPtrSetImpl<Value*> &Sources,
SmallPtrSetImpl<Instruction*> &Sinks,
SmallPtrSetImpl<Instruction*> &SafeToPromote) {
@@ -935,7 +935,7 @@ bool ARMCodeGenPrepare::TryToPromote(Value *V) {
SetVector<Value*> WorkList;
SmallPtrSet<Value*, 8> Sources;
SmallPtrSet<Instruction*, 4> Sinks;
- SmallPtrSet<Value*, 16> CurrentVisited;
+ SetVector<Value*> CurrentVisited;
WorkList.insert(V);
// Return true if V was added to the worklist as a supported instruction,
OpenPOWER on IntegriCloud