[PATCH] D134155: [RISCV]Preserve (and X, 0xffff) in targetShrinkDemandedConstant

Liao Chunyu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 18 19:20:01 PDT 2022


liaolucy added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:10045
   if (Opcode == ISD::AND) {
-    // Preserve (and X, 0xffff) when zext.h is supported.
-    if (Subtarget.hasStdExtZbb() || Subtarget.hasStdExtZbp()) {
-      APInt NewMask = APInt(Mask.getBitWidth(), 0xffff);
-      if (IsLegalMask(NewMask))
-        return UseMask(NewMask);
-    }
+    // Preserve (and X, 0xffff), if zext.h exists use zext.h,
+    // otherwise use SLLI + SRLI.
----------------
I'm actually not sure if there are side effects. 

I also implemented a version in RISCV DAGcombine, maybe it can be used as an alternative


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134155



More information about the llvm-commits mailing list