summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorSam Parker <sam.parker@arm.com>2018-09-13 14:48:10 +0000
committerSam Parker <sam.parker@arm.com>2018-09-13 14:48:10 +0000
commit96f77f142ba9b399435b09ac4a77af00f641d4e9 (patch)
tree5cae14542363d5405bb744b6a1d816c9e9889143 /llvm/lib/Target
parentc96cb25a8ba7baac5ad03545c5823032dbfa9ba4 (diff)
downloadbcm5719-llvm-96f77f142ba9b399435b09ac4a77af00f641d4e9.tar.gz
bcm5719-llvm-96f77f142ba9b399435b09ac4a77af00f641d4e9.zip
[ARM] Fix FixConst for ARMCodeGenPrepare
Part of FixConsts wrongly assumes either a 8- or 16-bit constant which can result in the wrong constants being generated during promotion. Differential Revision: https://reviews.llvm.org/D52032 llvm-svn: 342140
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp23
1 files changed, 3 insertions, 20 deletions
diff --git a/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp b/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp
index bc33e65b067..28bb482a3be 100644
--- a/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp
+++ b/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp
@@ -271,13 +271,6 @@ static bool isSafeOverflow(Instruction *I) {
return true;
}
- // Otherwise, if an instruction is using a negative immediate we will need
- // to fix it up during the promotion.
- for (auto &Op : I->operands()) {
- if (auto *Const = dyn_cast<ConstantInt>(Op))
- if (Const->isNegative())
- return false;
- }
return false;
}
@@ -370,19 +363,9 @@ void IRPromoter::Mutate(Type *OrigTy,
};
auto FixConst = [&](ConstantInt *Const, Instruction *I) {
- Constant *NewConst = nullptr;
- if (isSafeOverflow(I)) {
- NewConst = (Const->isNegative()) ?
- ConstantExpr::getSExt(Const, ExtTy) :
- ConstantExpr::getZExt(Const, ExtTy);
- } else {
- uint64_t NewVal = *Const->getValue().getRawData();
- if (Const->getType() == Type::getInt16Ty(Ctx))
- NewVal &= 0xFFFF;
- else
- NewVal &= 0xFF;
- NewConst = ConstantInt::get(ExtTy, NewVal);
- }
+ Constant *NewConst = isSafeOverflow(I) && Const->isNegative() ?
+ ConstantExpr::getSExt(Const, ExtTy) :
+ ConstantExpr::getZExt(Const, ExtTy);
I->replaceUsesOfWith(Const, NewConst);
};
OpenPOWER on IntegriCloud