[llvm] [RISCV] Improve instruction selection for most significant bit extraction (PR #151687)
Piotr Fusik via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 1 09:51:04 PDT 2025
================
@@ -1691,6 +1691,20 @@ multiclass SelectCC_GPR_riirr<DAGOperand valty, DAGOperand imm> {
valty:$truev, valty:$falsev), []>;
}
+let Predicates = [IsRV32] in {
+def : Pat<(i32 (seteq (i32 (and GPR:$rs1, 0xffffffff80000000)), 0)),
+ (XORI (i32 (SRLI GPR:$rs1, 31)), 1)>;
+def : Pat<(i32 (setlt (i32 GPR:$rs1), 0)), (SRLI GPR:$rs1, 31)>; // compressible
+}
+let Predicates = [IsRV64] in {
+def : Pat<(i64 (seteq (i64 (and GPR:$rs1, 0x8000000000000000)), 0)),
----------------
pfusik wrote:
Sounds like a good first change in tablegen. I can do that next week.
https://github.com/llvm/llvm-project/pull/151687
More information about the llvm-commits
mailing list