1; RUN: llc -march=aarch64 -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s
2
3; and can be eliminated
4; CHECK-LABEL: {{^}}test_call_known_max_range:
5; CHECK: bl foo
6; CHECK-NOT: and
7; CHECK: ret
8define i32 @test_call_known_max_range() #0 {
9entry:
10  %id = tail call i32 @foo(), !range !0
11  %and = and i32 %id, 1023
12  ret i32 %and
13}
14
15; CHECK-LABEL: {{^}}test_call_known_trunc_1_bit_range:
16; CHECK: bl foo
17; CHECK: and w{{[0-9]+}}, w0, #0x1ff
18; CHECK: ret
19define i32 @test_call_known_trunc_1_bit_range() #0 {
20entry:
21  %id = tail call i32 @foo(), !range !0
22  %and = and i32 %id, 511
23  ret i32 %and
24}
25
26; CHECK-LABEL: {{^}}test_call_known_max_range_m1:
27; CHECK: bl foo
28; CHECK: and w{{[0-9]+}}, w0, #0xff
29; CHECK: ret
30define i32 @test_call_known_max_range_m1() #0 {
31entry:
32  %id = tail call i32 @foo(), !range !1
33  %and = and i32 %id, 255
34  ret i32 %and
35}
36
37
38declare i32 @foo()
39
40attributes #0 = { norecurse nounwind }
41attributes #1 = { nounwind readnone }
42
43!0 = !{i32 0, i32 1024}
44!1 = !{i32 0, i32 1023}
45