[llvm] [RISCV] Lower flag check pattern to use a bitmask-shift (PR #169557)
Ryan Buchner via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 25 11:55:31 PST 2025
================
@@ -16736,6 +16736,52 @@ static SDValue combineOrAndToBitfieldInsert(SDNode *N, SelectionDAG &DAG,
return DAG.getNode(RISCVISD::QC_INSB, DL, MVT::i32, Ops);
}
+// or (icmp eq x, imm0), (icmp eq x, imm1) -> czero.eqz (sltui x, 64), (bext x,
+// 1 << imm0 | 1 << imm1) If [imm0, imm1] < 64
+static SDValue combineOrOfImmCmpToBitExtract(SDNode *N, SelectionDAG &DAG,
----------------
bababuck wrote:
I would prefer to make this optimization in `InstCombine`, but I can't because:
- I don't think we have a notion of the datapath width (xlen) at the IR level, and this optimization only makes sense if the comparison immediate is less than xlen
- `lshr` poison semantics, see https://alive2.llvm.org/ce/z/9MndvW
https://github.com/llvm/llvm-project/pull/169557
More information about the llvm-commits
mailing list