[llvm] [RISCV] Add BREV8 to SimplifyDemandedBitsForTargetNode. (PR #141898)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu May 29 08:20:04 PDT 2025


================
@@ -20717,6 +20716,35 @@ unsigned RISCVTargetLowering::ComputeNumSignBitsForTargetNode(
   return 1;
 }
 
+bool RISCVTargetLowering::SimplifyDemandedBitsForTargetNode(
+    SDValue Op, const APInt &OriginalDemandedBits,
+    const APInt &OriginalDemandedElts, KnownBits &Known, TargetLoweringOpt &TLO,
+    unsigned Depth) const {
+  unsigned BitWidth = OriginalDemandedBits.getBitWidth();
+
+  switch (Op.getOpcode()) {
+  case RISCVISD::BREV8: {
+    KnownBits Known2;
+    APInt DemandedBits =
+        APInt(BitWidth, computeGREVOrGORC(OriginalDemandedBits.getZExtValue(),
+                                          7, /*IsGORC=*/false));
+    if (SimplifyDemandedBits(Op.getOperand(0), DemandedBits,
+                             OriginalDemandedElts, Known2, TLO, Depth + 1))
+      return true;
+
+    // To compute zeros, we need to invert the value and invert it back after.
----------------
topperc wrote:

I changed it and removed the comment. I'll put it back when I add ORC_B as a follow up.

https://github.com/llvm/llvm-project/pull/141898


More information about the llvm-commits mailing list