[PATCH] D132718: [LoongArch] Combine add + shl to alsl.[w/d/wu]

WÁNG Xuěruì via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 25 23:39:29 PDT 2022


xen0n added a comment.

For the patch title: not all shifted additions can be expressed with `alsl.*` due to the limited imm range, so we could say `Combine eligible add + shl ...` to better convey the meaning.

Also you could add some more tests covering other possible choices of the imm, and one negative test case showing non-powers-of-2 multipliers are not covered. It may or may not be complete (that would probably cause the testcase number to explode), just some coverage would be nice.



================
Comment at: llvm/lib/Target/LoongArch/LoongArchInstrInfo.td:737
 
+/// Shift and add
+let Predicates = [IsLA32] in {
----------------
"Shifted addition"?


================
Comment at: llvm/lib/Target/LoongArch/LoongArchInstrInfo.td:745
+          (ALSL_D GPR:$rj, GPR:$rk, uimm2_plus1:$imm2)>;
+def : Pat<(loongarch_bstrpick (add GPR:$rk, (shl GPR:$rj, uimm2_plus1:$imm2)),
+                              (i64 31), (i64 0)),
----------------
This feels a bit weird, could a more generic node be used here instead of the rather concrete `bstrpick` one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132718



More information about the llvm-commits mailing list