1; RUN: llc -O2 -march=bpfel -mcpu=v2 -mattr=+alu32 < %s | FileCheck %s 2; 3; long long select_u(unsigned a, unsigned b, long long c, long long d) 4; { 5; if (a > b) 6; return c; 7; else 8; return d; 9; } 10; 11; long long select_u_2(unsigned a, unsigned long long b, long long c, long long d) 12; { 13; if (a > b) 14; return c; 15; else 16; return d; 17; } 18; 19; long long select_s(signed a, signed b, long long c, long long d) 20; { 21; if (a > b) 22; return c; 23; else 24; return d; 25; } 26; 27; long long bar (); 28; 29; int foo (int b, int c) 30; { 31; unsigned int i32_val = (unsigned int) bar(); 32; 33; if (i32_val < 10) 34; return b; 35; else 36; return c; 37; } 38; 39; int *inc_p (int *p, unsigned a) 40; { 41; return p + a; 42; } 43 44; Function Attrs: norecurse nounwind readnone 45define dso_local i64 @select_u(i32 %a, i32 %b, i64 %c, i64 %d) local_unnamed_addr #0 { 46; CHECK-LABEL: select_u: 47entry: 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 54 ret i64 %c.d 55} 56 57; Function Attrs: norecurse nounwind readnone 58define dso_local i64 @select_u_2(i32 %a, i64 %b, i64 %c, i64 %d) local_unnamed_addr #0 { 59; CHECK-LABEL: select_u_2: 60entry: 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 67 ret i64 %c.d 68} 69 70; Function Attrs: norecurse nounwind readnone 71define dso_local i64 @select_s(i32 %a, i32 %b, i64 %c, i64 %d) local_unnamed_addr #0 { 72; CHECK-LABEL: select_s: 73entry: 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 79 ret i64 %c.d 80} 81 82; Function Attrs: nounwind 83define dso_local i32 @foo(i32 %b, i32 %c) local_unnamed_addr #0 { 84; CHECK-LABEL: foo: 85entry: 86 %call = tail call i64 bitcast (i64 (...)* @bar to i64 ()*)() #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 90; to be cleared. 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 96 ret i32 %b.c 97} 98 99declare dso_local i64 @bar(...) local_unnamed_addr #1 100 101; Function Attrs: norecurse nounwind readnone 102define dso_local i32* @inc_p(i32* readnone %p, i32 %a) local_unnamed_addr #0 { 103; CHECK-LABEL: inc_p: 104entry: 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, i32* %p, i64 %idx.ext 110 ret i32* %add.ptr 111} 112 113define dso_local i32 @test() local_unnamed_addr { 114; CHECK-LABEL: test: 115entry: 116 %call = tail call i32 bitcast (i32 (...)* @helper to i32 ()*)() 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 124 ret i32 %cond 125} 126declare dso_local i32 @helper(...) local_unnamed_addr 127