[PATCH] D116574: Materializing constants with 'rori'

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 4 11:12:56 PST 2022


craig.topper added inline comments.


================
Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp:146
+  bool Ret = false;
+  int LeadingOnes = countLeadingOnes((uint64_t)Val);
+  int TrailingOnes = countTrailingOnes((uint64_t)Val);
----------------
Use `unsigned` instead of `int`


================
Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp:149
+  // for case: 0xffffff77ffffffff
+  if (LeadingOnes < 32 && ((64 - LeadingOnes - TrailingOnes) < 12)) {
+    NegImm12 = ((uint64_t)Val >> TrailingOnes) | (Val << (64 - TrailingOnes));
----------------
Can we do this for LeadingOnes == 32 too? For example 0xffffffff77ffffff. That can't use LUI+ADDIW.


================
Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp:154
+  } else {
+    int UpperTrailingOnes = countTrailingOnes((uint64_t)(Val >> 32));
+    int LowerLeadingOnes = countLeadingOnes((uint64_t)(Val << 32));
----------------
Can this use Lo_32 and Hi_32 from MathExtras.h? Or is the signed right shift important?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116574



More information about the llvm-commits mailing list