1; RUN: llc -O2 -march=bpfel -mcpu=v2 -mattr=+alu32 < %s | FileCheck %s
2;
3; For the below test case, 'b' in 'ret == b' needs SLL/SLR.
4; 'ret' in 'ret == b' does not need SLL/SLR as all 'ret' values
5; are assigned through 'w<reg> = <value>' alu32 operations.
6;
7; extern int helper(int);
8; int test(int a, int b, int c, int d) {
9;   int ret;
10;   if (a < b)
11;     ret = (c < d) ? -1 : 0;
12;   else
13;     ret = (c < a) ? 1 : 2;
14;   return helper(ret == b);
15; }
16
17define dso_local i32 @test(i32 %a, i32 %b, i32 %c, i32 %d) local_unnamed_addr {
18entry:
19  %cmp = icmp slt i32 %a, %b
20  %cmp1 = icmp slt i32 %c, %d
21  %cond = sext i1 %cmp1 to i32
22  %cmp2 = icmp slt i32 %c, %a
23  %cond3 = select i1 %cmp2, i32 1, i32 2
24  %ret.0 = select i1 %cmp, i32 %cond, i32 %cond3
25  %cmp4 = icmp eq i32 %ret.0, %b
26  %conv = zext i1 %cmp4 to i32
27  %call = tail call i32 @helper(i32 %conv)
28  ret i32 %call
29}
30; CHECK: r{{[0-9]+}} = w{{[0-9]+}}
31; CHECK-NOT: r{{[0-9]+}} >>= 32
32; CHECK: if r{{[0-9]+}} == r{{[0-9]+}} goto
33
34declare dso_local i32 @helper(i32) local_unnamed_addr
35