Skip to content

Commit 3d73525

Browse files
committed
[X86] Add test coverage for some i64 cmp+srl+add cases
1 parent 04e5ea5 commit 3d73525

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefixes=X64
3+
4+
; Test for https://github.com/llvm/llvm-project/issues/123239
5+
6+
define i1 @test_ult_trunc_add(i64 %x) {
7+
; X64-LABEL: test_ult_trunc_add:
8+
; X64: # %bb.0: # %entry
9+
; X64-NEXT: movabsq $3940649673949184, %rax # imm = 0xE000000000000
10+
; X64-NEXT: addq %rdi, %rax
11+
; X64-NEXT: shrq $48, %rax
12+
; X64-NEXT: cmpl $3, %eax
13+
; X64-NEXT: setb %al
14+
; X64-NEXT: retq
15+
entry:
16+
%add = add i64 %x, 3940649673949184
17+
%shr = lshr i64 %add, 48
18+
%conv = trunc i64 %shr to i32
19+
%res = icmp ult i32 %conv, 3
20+
ret i1 %res
21+
}
22+
23+
define i1 @test_ult_add(i64 %x) {
24+
; X64-LABEL: test_ult_add:
25+
; X64: # %bb.0: # %entry
26+
; X64-NEXT: movabsq $3940649673949184, %rax # imm = 0xE000000000000
27+
; X64-NEXT: addq %rdi, %rax
28+
; X64-NEXT: shrq $48, %rax
29+
; X64-NEXT: cmpl $3, %eax
30+
; X64-NEXT: setb %al
31+
; X64-NEXT: retq
32+
entry:
33+
%0 = add i64 3940649673949184, %x
34+
%1 = icmp ult i64 %0, 844424930131968
35+
ret i1 %1
36+
}
37+
38+
define i1 @test_ugt_trunc_add(i64 %x) {
39+
; X64-LABEL: test_ugt_trunc_add:
40+
; X64: # %bb.0: # %entry
41+
; X64-NEXT: movabsq $3940649673949184, %rax # imm = 0xE000000000000
42+
; X64-NEXT: addq %rdi, %rax
43+
; X64-NEXT: shrq $48, %rax
44+
; X64-NEXT: cmpl $4, %eax
45+
; X64-NEXT: setae %al
46+
; X64-NEXT: retq
47+
entry:
48+
%add = add i64 %x, 3940649673949184
49+
%shr = lshr i64 %add, 48
50+
%conv = trunc i64 %shr to i32
51+
%res = icmp ugt i32 %conv, 3
52+
ret i1 %res
53+
}
54+
55+
define i1 @test_ugt_add(i64 %x) {
56+
; X64-LABEL: test_ugt_add:
57+
; X64: # %bb.0: # %entry
58+
; X64-NEXT: movabsq $3940649673949184, %rax # imm = 0xE000000000000
59+
; X64-NEXT: addq %rdi, %rax
60+
; X64-NEXT: movabsq $844424930131968, %rcx # imm = 0x3000000000000
61+
; X64-NEXT: cmpq %rcx, %rax
62+
; X64-NEXT: seta %al
63+
; X64-NEXT: retq
64+
entry:
65+
%0 = add i64 3940649673949184, %x
66+
%1 = icmp ugt i64 %0, 844424930131968
67+
ret i1 %1
68+
}
69+
70+
define i1 @test_eq_trunc_add(i64 %x) {
71+
; X64-LABEL: test_eq_trunc_add:
72+
; X64: # %bb.0: # %entry
73+
; X64-NEXT: movabsq $3940649673949184, %rax # imm = 0xE000000000000
74+
; X64-NEXT: addq %rdi, %rax
75+
; X64-NEXT: shrq $48, %rax
76+
; X64-NEXT: cmpl $3, %eax
77+
; X64-NEXT: sete %al
78+
; X64-NEXT: retq
79+
entry:
80+
%add = add i64 %x, 3940649673949184
81+
%shr = lshr i64 %add, 48
82+
%conv = trunc i64 %shr to i32
83+
%res = icmp eq i32 %conv, 3
84+
ret i1 %res
85+
}
86+
87+
define i1 @test_eq_add(i64 %x) {
88+
; X64-LABEL: test_eq_add:
89+
; X64: # %bb.0: # %entry
90+
; X64-NEXT: movabsq $-3096224743817216, %rax # imm = 0xFFF5000000000000
91+
; X64-NEXT: cmpq %rax, %rdi
92+
; X64-NEXT: sete %al
93+
; X64-NEXT: retq
94+
entry:
95+
%0 = add i64 3940649673949184, %x
96+
%1 = icmp eq i64 %0, 844424930131968
97+
ret i1 %1
98+
}
99+
100+
define i1 @test_ne_trunc_add(i64 %x) {
101+
; X64-LABEL: test_ne_trunc_add:
102+
; X64: # %bb.0: # %entry
103+
; X64-NEXT: movabsq $3940649673949184, %rax # imm = 0xE000000000000
104+
; X64-NEXT: addq %rdi, %rax
105+
; X64-NEXT: shrq $48, %rax
106+
; X64-NEXT: cmpl $3, %eax
107+
; X64-NEXT: setne %al
108+
; X64-NEXT: retq
109+
entry:
110+
%add = add i64 %x, 3940649673949184
111+
%shr = lshr i64 %add, 48
112+
%conv = trunc i64 %shr to i32
113+
%res = icmp ne i32 %conv, 3
114+
ret i1 %res
115+
}
116+
117+
define i1 @test_ne_add(i64 %x) {
118+
; X64-LABEL: test_ne_add:
119+
; X64: # %bb.0: # %entry
120+
; X64-NEXT: movabsq $-3096224743817216, %rax # imm = 0xFFF5000000000000
121+
; X64-NEXT: cmpq %rax, %rdi
122+
; X64-NEXT: setne %al
123+
; X64-NEXT: retq
124+
entry:
125+
%0 = add i64 3940649673949184, %x
126+
%1 = icmp ne i64 %0, 844424930131968
127+
ret i1 %1
128+
}

0 commit comments

Comments
 (0)