Skip to content

Commit

Permalink
Merged master:948e745270d into amd-gfx:6760a4d8875
Browse files Browse the repository at this point in the history
Local branch amd-gfx 6760a4d Merged master:4a188fdfa79 into amd-gfx:e10a557109a
Remote branch master 948e745 [LV][NFC] Keep dominator tree up to date during vectorization.
  • Loading branch information
Sw authored and Sw committed Dec 30, 2019
2 parents 6760a4d + 948e745 commit 4d562be
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 164 deletions.
75 changes: 33 additions & 42 deletions llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,50 +303,41 @@ void llvm::emitT2RegPlusImmediate(MachineBasicBlock &MBB,
continue;
}

assert((DestReg != ARM::SP || BaseReg == ARM::SP) &&
"Writing to SP, from other register.");

// Try to use T1, as it smaller
if ((DestReg == ARM::SP) && (ThisVal < ((1 << 7) - 1) * 4)) {
assert((ThisVal & 3) == 0 && "Stack update is not multiple of 4?");
Opc = isSub ? ARM::tSUBspi : ARM::tADDspi;
BuildMI(MBB, MBBI, dl, TII.get(Opc), DestReg)
.addReg(BaseReg)
.addImm(ThisVal / 4)
.setMIFlags(MIFlags)
.add(predOps(ARMCC::AL));
break;
}
bool HasCCOut = true;
if (BaseReg == ARM::SP) {
// sub sp, sp, #imm7
if (DestReg == ARM::SP && (ThisVal < ((1 << 7)-1) * 4)) {
assert((ThisVal & 3) == 0 && "Stack update is not multiple of 4?");
Opc = isSub ? ARM::tSUBspi : ARM::tADDspi;
BuildMI(MBB, MBBI, dl, TII.get(Opc), DestReg)
.addReg(BaseReg)
.addImm(ThisVal / 4)
.setMIFlags(MIFlags)
.add(predOps(ARMCC::AL));
NumBytes = 0;
continue;
}

// sub rd, sp, so_imm
Opc = isSub ? ARM::t2SUBri : ARM::t2ADDri;
if (ARM_AM::getT2SOImmVal(NumBytes) != -1) {
NumBytes = 0;
} else {
// FIXME: Move this to ARMAddressingModes.h?
unsigned RotAmt = countLeadingZeros(ThisVal);
ThisVal = ThisVal & ARM_AM::rotr32(0xff000000U, RotAmt);
NumBytes &= ~ThisVal;
assert(ARM_AM::getT2SOImmVal(ThisVal) != -1 &&
"Bit extraction didn't work?");
}
int ImmIsT2SO = ARM_AM::getT2SOImmVal(ThisVal);

Opc = isSub ? ARM::t2SUBri : ARM::t2ADDri;
// Prefer T2: sub rd, rn, so_imm | sub sp, sp, so_imm
if (ImmIsT2SO != -1) {
NumBytes = 0;
} else if (ThisVal < 4096) {
// Prefer T3 if can make it in a single go: subw rd, rn, imm12 | subw sp,
// sp, imm12
Opc = isSub ? ARM::t2SUBri12 : ARM::t2ADDri12;
HasCCOut = false;
NumBytes = 0;
} else {
assert(DestReg != ARM::SP && BaseReg != ARM::SP);
Opc = isSub ? ARM::t2SUBri : ARM::t2ADDri;
if (ARM_AM::getT2SOImmVal(NumBytes) != -1) {
NumBytes = 0;
} else if (ThisVal < 4096) {
Opc = isSub ? ARM::t2SUBri12 : ARM::t2ADDri12;
HasCCOut = false;
NumBytes = 0;
} else {
// FIXME: Move this to ARMAddressingModes.h?
unsigned RotAmt = countLeadingZeros(ThisVal);
ThisVal = ThisVal & ARM_AM::rotr32(0xff000000U, RotAmt);
NumBytes &= ~ThisVal;
assert(ARM_AM::getT2SOImmVal(ThisVal) != -1 &&
"Bit extraction didn't work?");
}
// Use one T2 instruction to reduce NumBytes
// FIXME: Move this to ARMAddressingModes.h?
unsigned RotAmt = countLeadingZeros(ThisVal);
ThisVal = ThisVal & ARM_AM::rotr32(0xff000000U, RotAmt);
NumBytes &= ~ThisVal;
assert(ARM_AM::getT2SOImmVal(ThisVal) != -1 &&
"Bit extraction didn't work?");
}

// Build the new ADD / SUB.
Expand Down
Loading

0 comments on commit 4d562be

Please sign in to comment.