[PATCH] D134336: [AArch64] Lower multiplication by a constant int to madd

Allen zhong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 27 21:25:48 PDT 2022


Allen added inline comments.


================
Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.cpp:5922
+        BuildMI(MF, Root.getDebugLoc(), TII->get(MovI->Opcode), NewVR)
+            .addImm(MovI->Op1)
+            .addImm(MovI->Op2);
----------------
efriedma wrote:
> Sorry, missed an issue here the first time I looked at this...
> 
> The current complete set of opcodes that immediate expansion can produce is listed in AArch64ExpandPseudo::expandMOVImm .  If the opcode is movz/movn, there are two immediate operands.  But the opcode can also be ORRWri/ORRXri; in that case, there a register operand (wzr/xzr), and an immediate operand.
> 
> I think this comes up for something like `int f(int a) { return a * 44 + 16773120; }`.
Despite  the fact that movz/movn have two immediate operands, but it will generate a mov as alias, which only has one  immediate operand.
see the following code frag in AArch64_IMM::expandMOVImm.
```
  // Prefer MOVZ/MOVN over ORR because of the rules for the "mov" alias.
  if ((BitSize / 16) - OneChunks <= 1 || (BitSize / 16) - ZeroChunks <= 1) {
    expandMOVImmSimple(Imm, BitSize, OneChunks, ZeroChunks, Insn);
    return;
  }
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134336/new/

https://reviews.llvm.org/D134336



More information about the llvm-commits mailing list