[llvm] [X86] Try to shrink signed i64 compares if the input has enough one bits (PR #149719)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 21 00:41:26 PDT 2025
================
@@ -956,3 +956,15 @@ define i1 @fold_test_and_with_chain(ptr %x, ptr %y, i32 %z) {
store i32 %z, ptr %y
ret i1 %c
}
+
+define i1 @sext_mask(i32 %a) {
----------------
RKSimon wrote:
You need extract tests to better exercise this fold.
For the cmp with constant, something like these (I just copy+pasteed - please add different CondCode and constants):
```
define i1 @sext_i9_mask(i9 %a) {
%a64 = sext i9 %a to i64
%v1 = icmp slt i64 %a64, -523
ret i1 %v1
}
define i1 @sext_i32_mask(i32 %a) {
%a64 = sext i32 %a to i64
%v1 = icmp slt i64 %a64, -523
ret i1 %v1
}
define i1 @i40(i40 %a) {
%a64 = sext i40 %a to i64
%v1 = icmp slt i64 %a64, -523
ret i1 %v1
}
```
You should also add some tests with comparison of 2 (sign/zero extended) variables - possibly different source sizes.
https://github.com/llvm/llvm-project/pull/149719
More information about the llvm-commits
mailing list