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

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 18 19:36:04 PDT 2022


craig.topper 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.
----------------
liaolucy wrote:
> 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
What does the DAGCombine do? When it get in an infinite loop with shrinkDemandedConstant?


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