Skip to content

Commit

Permalink
[PowerPC] avoid redundant analysis while lowering an immediate; NFC
Browse files Browse the repository at this point in the history
This patch reduces compilation time by avoiding redundant analysis while selecting instructions to create an immediate.
If the instruction count required to create the input number without rotate is 2, we do not need further analysis to find a shorter instruction sequence with rotate; rotate + load constant cannot be done by 1 instruction (i.e. getInt64CountDirectnever return 0).
This patch should not change functionality.

Differential Revision: https://reviews.llvm.org/D34986

llvm-svn: 307623
  • Loading branch information
inouehrs committed Jul 11, 2017
1 parent 946ab55 commit f55ee1b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
Expand Up @@ -709,7 +709,10 @@ static uint64_t Rot64(uint64_t Imm, unsigned R) {

static unsigned getInt64Count(int64_t Imm) {
unsigned Count = getInt64CountDirect(Imm);
if (Count == 1)

// If the instruction count is 1 or 2, we do not need further analysis
// since rotate + load constant requires at least 2 instructions.
if (Count <= 2)
return Count;

for (unsigned r = 1; r < 63; ++r) {
Expand Down Expand Up @@ -819,7 +822,10 @@ static SDNode *getInt64Direct(SelectionDAG *CurDAG, const SDLoc &dl,

static SDNode *getInt64(SelectionDAG *CurDAG, const SDLoc &dl, int64_t Imm) {
unsigned Count = getInt64CountDirect(Imm);
if (Count == 1)

// If the instruction count is 1 or 2, we do not need further analysis
// since rotate + load constant requires at least 2 instructions.
if (Count <= 2)
return getInt64Direct(CurDAG, dl, Imm);

unsigned RMin = 0;
Expand Down

0 comments on commit f55ee1b

Please sign in to comment.