[PATCH] D103743: [RISCV] Optimize bitwise and with constant for the Zbs extension

Luís Marques via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 7 06:26:51 PDT 2021


luismarques added a comment.

Are you planning on extending this to use bclriw on RV64? (Would that clash with the use of tablegen? Personally, I tend to find C++ custom lowering of longer stuff easier to read and more cohesive, not sure how others feel)



================
Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoB.td:140
+  // The immediate must have exactly two bits clear.
+  uint64_t I = static_cast<uint64_t>(N->getSExtValue());
+  if (!Subtarget->is64Bit())
----------------
Drop the explicit cast to uint64_t?


================
Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoB.td:141-143
+  if (!Subtarget->is64Bit())
+    I |= 0xffffffffull << 32;
+  return countPopulation(~I) == 2;
----------------
I found this a bit confusing when I first read it. I suppose an alternative would be to replace the three lines with something like `return countPopulation(I) == XLen - 2`?


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

https://reviews.llvm.org/D103743



More information about the llvm-commits mailing list