Skip to content

Commit

Permalink
Thumb2 IT blocks are fairly expensive. When there are multiple select…
Browse files Browse the repository at this point in the history
…s using

the same condition, it's important to make sure they are scheduled together
to avoid forming multiple IT blocks. I'm adding a pre-regalloc pass that forms
IT blocks early (by re-scheduling instructions and split basic blocks) to
attempt to fix this. This is not turned on by default since I am not sure this
is the right fix.

Another issue is llvm selects are modeled as two-address conditional moves.
This can be very bad when the copies before the conditional moves are not
coalesced away. Teach IT formation pass to move the copies above the IT block
(when legal) to avoid breaking the IT block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105669 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Evan Cheng committed Jun 9, 2010
1 parent 6c060db commit d847124
Show file tree
Hide file tree
Showing 3 changed files with 292 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/Target/ARM/ARM.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ FunctionPass *createARMExpandPseudoPass();
FunctionPass *createARMConstantIslandPass();
FunctionPass *createNEONPreAllocPass();
FunctionPass *createNEONMoveFixPass();
FunctionPass *createThumb2ITBlockPass();
FunctionPass *createThumb2ITBlockPass(bool PreAlloc = false);
FunctionPass *createThumb2SizeReductionPass();

extern Target TheARMTarget, TheThumbTarget;
Expand Down
10 changes: 10 additions & 0 deletions lib/Target/ARM/ARMTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@
#include "ARM.h"
#include "llvm/PassManager.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetRegistry.h"
using namespace llvm;

static cl::opt<bool>
EarlyITBlockFormation("thumb2-early-it-blocks", cl::Hidden,
cl::desc("Form IT blocks earlt, before register allocation"),
cl::init(false));

static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
Triple TheTriple(TT);
switch (TheTriple.getOS()) {
Expand Down Expand Up @@ -98,6 +104,10 @@ bool ARMBaseTargetMachine::addPreRegAlloc(PassManagerBase &PM,
// FIXME: temporarily disabling load / store optimization pass for Thumb1.
if (OptLevel != CodeGenOpt::None && !Subtarget.isThumb1Only())
PM.add(createARMLoadStoreOptimizationPass(true));

if (OptLevel != CodeGenOpt::None && Subtarget.isThumb2() &&
EarlyITBlockFormation)
PM.add(createThumb2ITBlockPass(true));
return true;
}

Expand Down
Loading

0 comments on commit d847124

Please sign in to comment.