[llvm] [RISCV] Improve instruction selection for most significant bit extraction (PR #151687)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 1 09:33:51 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)),
----------------
topperc wrote:
I think you have to fix that in tablegen. `-9223372036854775808` is parsed as two tokens, `-` and `9223372036854775808`. The `9223372036854775808` doesn't fit in a signed 64-bit value. Maybe need to detect this case and use INT64_MIN instead?
https://github.com/llvm/llvm-project/pull/151687
More information about the llvm-commits
mailing list