Skip to content

Commit 1f5413f

Browse files
[layout][AArch64] Do not convert ADDS/SUBS back to three-address
The `ADDS/SUBS` MIR instructions are usually used in implementing conditions since they set the condition flags. Because X86 uses `CMP`-like instructions for the same purpose, which follow the two-address format, we avoid converting these AArch64 instructions back to the three-address format during the `twoaddressinstruction` pass. This way, they retain the two-address format which we have imposed.
1 parent d3199ba commit 1f5413f

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5625,14 +5625,18 @@ MachineInstr *AArch64InstrInfo::convertToThreeAddress(
56255625
switch (MIOpc) {
56265626
default:
56275627
llvm_unreachable("Unreachable!");
5628-
case AArch64::ADDXrr:
5629-
case AArch64::ADDWrr:
56305628
case AArch64::ADDSXrr:
56315629
case AArch64::ADDSWrr:
5632-
case AArch64::SUBXrr:
5633-
case AArch64::SUBWrr:
56345630
case AArch64::SUBSXrr:
56355631
case AArch64::SUBSWrr:
5632+
// For the instructions that set the flags, do not turn them back into the
5633+
// three-address format, since the equivalent X86 instructions (usually
5634+
// CMP-like) have the two-address format.
5635+
return nullptr;
5636+
case AArch64::ADDXrr:
5637+
case AArch64::ADDWrr:
5638+
case AArch64::SUBXrr:
5639+
case AArch64::SUBWrr:
56365640
assert(MI.getNumOperands() >= 3 && "Unknown add/sub instruction!");
56375641
unsigned Opc = MIOpc;
56385642

0 commit comments

Comments
 (0)