1 ; RUN: llc -O2 -march=bpfel -mcpu=v2 -mattr=+alu32 < %s | FileCheck %s
3 ; long long select_u(unsigned a, unsigned b, long long c, long long d)
11 ; long long select_u_2(unsigned a, unsigned long long b, long long c, long long d)
19 ; long long select_s(signed a, signed b, long long c, long long d)
29 ; int foo (int b, int c)
31 ; unsigned int i32_val = (unsigned int) bar();
39 ; int *inc_p (int *p, unsigned a)
44 ; Function Attrs: norecurse nounwind readnone
45 define dso_local i64 @select_u(i32 %a, i32 %b, i64 %c, i64 %d) local_unnamed_addr #0 {
46 ; CHECK-LABEL: select_u:
48 %cmp = icmp ugt i32 %a, %b
49 %c.d = select i1 %cmp, i64 %c, i64 %d
50 ; CHECK: r{{[0-9]+}} = w{{[0-9]+}}
51 ; CHECK-NOT: r{{[0-9]+}} <<= 32
52 ; CHECK-NOT: r{{[0-9]+}} >>= 32
53 ; CHECK: if r{{[0-9]+}} {{<|>}} r{{[0-9]+}} goto
57 ; Function Attrs: norecurse nounwind readnone
58 define dso_local i64 @select_u_2(i32 %a, i64 %b, i64 %c, i64 %d) local_unnamed_addr #0 {
59 ; CHECK-LABEL: select_u_2:
61 %conv = zext i32 %a to i64
62 ; CHECK: r{{[0-9]+}} = w{{[0-9]+}}
63 ; CHECK-NOT: r{{[0-9]+}} <<= 32
64 ; CHECK-NOT: r{{[0-9]+}} >>= 32
65 %cmp = icmp ugt i64 %conv, %b
66 %c.d = select i1 %cmp, i64 %c, i64 %d
70 ; Function Attrs: norecurse nounwind readnone
71 define dso_local i64 @select_s(i32 %a, i32 %b, i64 %c, i64 %d) local_unnamed_addr #0 {
72 ; CHECK-LABEL: select_s:
74 %cmp = icmp sgt i32 %a, %b
75 %c.d = select i1 %cmp, i64 %c, i64 %d
76 ; CHECK: r{{[0-9]+}} <<= 32
77 ; CHECK-NEXT: r{{[0-9]+}} s>>= 32
78 ; CHECK: if r{{[0-9]+}} s{{<|>}} r{{[0-9]+}} goto
82 ; Function Attrs: nounwind
83 define dso_local i32 @foo(i32 %b, i32 %c) local_unnamed_addr #0 {
86 %call = tail call i64 @bar() #2
87 %conv = trunc i64 %call to i32
88 %cmp = icmp ult i32 %conv, 10
89 ; %call comes from function call returning i64 so the high bits will need
91 ; CHECK: r{{[0-9]+}} = w{{[0-9]+}}
92 ; CHECK-NOT: r{{[0-9]+}} <<= 32
93 ; CHECK-NOT: r{{[0-9]+}} >>= 32
94 %b.c = select i1 %cmp, i32 %b, i32 %c
95 ; CHECK: if r{{[0-9]+}} {{<|>}} {{[0-9]+}} goto
99 declare dso_local i64 @bar(...) local_unnamed_addr #1
101 ; Function Attrs: norecurse nounwind readnone
102 define dso_local ptr @inc_p(ptr readnone %p, i32 %a) local_unnamed_addr #0 {
103 ; CHECK-LABEL: inc_p:
105 %idx.ext = zext i32 %a to i64
106 ; CHECK: r{{[0-9]+}} = w{{[0-9]+}}
107 ; CHECK-NOT: r{{[0-9]+}} <<= 32
108 ; CHECK-NOT: r{{[0-9]+}} >>= 32
109 %add.ptr = getelementptr inbounds i32, ptr %p, i64 %idx.ext
113 define dso_local i32 @test() local_unnamed_addr {
116 %call = tail call i32 @helper()
117 %cmp = icmp sgt i32 %call, 6
118 ; The shifts can't be optimized out because %call comes from function call
119 ; return i32 so the high bits might be invalid.
120 ; CHECK: r{{[0-9]+}} <<= 32
121 ; CHECK-NEXT: r{{[0-9]+}} s>>= 32
122 %cond = zext i1 %cmp to i32
123 ; CHECK: if r{{[0-9]+}} s{{<|>}} {{[0-9]+}} goto
126 declare dso_local i32 @helper(...) local_unnamed_addr