[llvm-branch-commits] [llvm] [AArch64][PAC] Eliminate excessive MOVs when computing blend (PR #115185)
Anatoly Trosinenko via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Nov 11 08:38:35 PST 2024
================
@@ -163,8 +163,15 @@ class AArch64AsmPrinter : public AsmPrinter {
// Emit the sequence for AUT or AUTPAC.
void emitPtrauthAuthResign(const MachineInstr *MI);
- // Emit the sequence to compute a discriminator into x17, or reuse AddrDisc.
- unsigned emitPtrauthDiscriminator(uint16_t Disc, unsigned AddrDisc);
+ // Emit the sequence to compute the discriminator.
+ // ScratchReg should be x16/x17.
+ // The returned register is either unmodified AddrDisc or x16/x17.
+ // If the expanded pseudo is allowed to clobber AddrDisc register, setting
+ // MayUseAddrAsScratch may save one MOV instruction, provided the address
----------------
atrosinenko wrote:
I agree the comment is not very clear - hopefully the updated version is more readable. The reason that the commit message mentions two instructions and this comment mentions only one is that the second `mov` is saved due to relaxing the register class.
When the particular instruction clobbers both x16 and x17 and AddrDisc is not used after the discriminator is computed, by relaxing the register class this
```
ldr x9, [x16]
mov x8, x16
mov x17, x8
movk x17, #34646, lsl #48
blraa x9, x17
```
can be simplified to
```
ldr x8, [x16]
mov x17, x16
movk x17, #34646, lsl #48
blraa x8, x17
```
which can be further simplified to
```
ldr x8, [x16]
movk x16, #34646, lsl #48
blraa x8, x16
```
by reusing AddrDisc in-place.
https://github.com/llvm/llvm-project/pull/115185
More information about the llvm-branch-commits
mailing list