summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSam Parker <sam.parker@arm.com>2019-12-11 09:55:40 +0000
committerSam Parker <sam.parker@arm.com>2019-12-11 10:00:16 +0000
commitee7579409b7d940c4e1314d126e900db30c4edff (patch)
tree31631d87e08fec55dfb5da408b3b30349da05248 /llvm/lib
parenteba7cbd3d06b3a84a72dcb6601a667a095c32664 (diff)
downloadbcm5719-llvm-ee7579409b7d940c4e1314d126e900db30c4edff.tar.gz
bcm5719-llvm-ee7579409b7d940c4e1314d126e900db30c4edff.zip
[ARM][TypePromotion] Enable by default
Enable the TypePromotion pass my default (again). This patch was originally committed in 393dacacf7e7. This patch was reverted in a38396939c54. Differential Revision: https://reviews.llvm.org/D70998
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/TypePromotion.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TypePromotion.cpp b/llvm/lib/CodeGen/TypePromotion.cpp
index d78589c4a05..000cd366dd6 100644
--- a/llvm/lib/CodeGen/TypePromotion.cpp
+++ b/llvm/lib/CodeGen/TypePromotion.cpp
@@ -46,7 +46,7 @@
using namespace llvm;
static cl::opt<bool>
-DisablePromotion("disable-type-promotion", cl::Hidden, cl::init(true),
+DisablePromotion("disable-type-promotion", cl::Hidden, cl::init(false),
cl::desc("Disable type promotion pass"));
// The goal of this pass is to enable more efficient code generation for
@@ -902,16 +902,34 @@ bool TypePromotion::TryToPromote(Value *V, unsigned PromotedWidth) {
for (auto *I : CurrentVisited)
I->dump();
);
+
+ // Check that promoting this at the IR level is most likely beneficial. It's
+ // more likely if we're operating over multiple blocks and handling wrapping
+ // instructions.
unsigned ToPromote = 0;
+ unsigned NonFreeArgs = 0;
+ SmallPtrSet<BasicBlock*, 4> Blocks;
for (auto *V : CurrentVisited) {
- if (Sources.count(V))
+ if (auto *I = dyn_cast<Instruction>(V))
+ Blocks.insert(I->getParent());
+
+ if (Sources.count(V)) {
+ if (auto *Arg = dyn_cast<Argument>(V)) {
+ if (!Arg->hasZExtAttr() && !Arg->hasSExtAttr())
+ ++NonFreeArgs;
+ }
continue;
+ }
+
if (Sinks.count(cast<Instruction>(V)))
continue;
+
++ToPromote;
}
- if (ToPromote < 2)
+ // DAG optimisations should be able to handle these cases better, especially
+ // for function arguments.
+ if (ToPromote < 2 || (Blocks.size() == 1 && (NonFreeArgs > SafeWrap.size())))
return false;
Promoter->Mutate(OrigTy, PromotedWidth, CurrentVisited, Sources, Sinks,
OpenPOWER on IntegriCloud