[llvm] [RISCV] Add isel special case for (and (shl X, c2), c1) -> (slli_uw (srli x, c4-c2), c4). (PR #91638)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu May 9 12:00:26 PDT 2024


================
@@ -1350,6 +1350,21 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
             return;
           }
         }
+
+        // Turn (and (shl x, c2), c1) -> (slli_uw (srli x, c4-c2), c4) where c1
+        // is shifted mask with 32 set bits and c4 trailing zeros.
+        unsigned Trailing = llvm::countr_zero(C1);
+        if (Leading + Trailing == 32 && C2 < Trailing &&
----------------
preames wrote:

Do we need a !IsCANDI check here?

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


More information about the llvm-commits mailing list