[PATCH] D139813: [PowerPC] Improve materialization for immediates which is almost a 32 bit splat.

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 23 03:08:42 PST 2022


shchenz added inline comments.


================
Comment at: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1334
+  // splat of a 32 bit immediate.
+  if (InstCntDirect > 4) {
+    uint32_t Hi16OfHi32 = (Hi_32(Imm) >> 16) & 0xffff;
----------------
For compile time concern, since the 1 instruction patterns for `Imm & 0xffffffff00000000` are simple, can we move the new code before line 1318 and do some simple check for 1 instruction pattern in `selectI64ImmDirect`? 


================
Comment at: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1341
+    auto getSplat = [CurDAG, dl](uint32_t Hi16, uint32_t Lo16) {
+      auto getI32Imm = [CurDAG, dl](unsigned Imm) {
+        return CurDAG->getTargetConstant(Imm, dl, MVT::i32);
----------------
nit: there is a `getI32Imm` lambda at line 1314. 


================
Comment at: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1357
+      Result = CurDAG->getMachineNode(
+          PPC::ORI8, dl, MVT::i64, SDValue(Result, 0),
+          CurDAG->getTargetConstant(Lo16OfLo32, dl, MVT::i32));
----------------
I don't get the point here.
original input: 0xAAAABBBBAAAACCCC
splat result: 0XAAAABBBBAAAABBBB
after the ORI8: 0XAAAABBBBAAAABBBB | 0xCCCC != 0xAAAABBBBAAAACCCC ?

Seems another `rldimi` is needed to insert `Lo16OfLo32` to the splat result.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139813



More information about the llvm-commits mailing list