brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 18ae3b7 Raw
127 lines · plain
1; RUN: llc -O2 -mtriple=bpfel -mcpu=v2 -mattr=+alu32 < %s | FileCheck %s2;3; long long select_u(unsigned a, unsigned b, long long c, long long d)4; {5;   if (a > b)6;     return c;7;   else8;     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;   else16;     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;   else24;     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;   else36;     return c;37; }38;39; int *inc_p (int *p, unsigned a)40; {41;   return p + a;42; }43 44; Function Attrs: norecurse nounwind readnone45define 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, %b49  %c.d = select i1 %cmp, i64 %c, i64 %d50; CHECK: r{{[0-9]+}} = w{{[0-9]+}}51; CHECK-NOT: r{{[0-9]+}} <<= 3252; CHECK-NOT: r{{[0-9]+}} >>= 3253; CHECK: if r{{[0-9]+}} {{<|>}} r{{[0-9]+}} goto54  ret i64 %c.d55}56 57; Function Attrs: norecurse nounwind readnone58define 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 i6462; CHECK: r{{[0-9]+}} = w{{[0-9]+}}63; CHECK-NOT: r{{[0-9]+}} <<= 3264; CHECK-NOT: r{{[0-9]+}} >>= 3265  %cmp = icmp ugt i64 %conv, %b66  %c.d = select i1 %cmp, i64 %c, i64 %d67  ret i64 %c.d68}69 70; Function Attrs: norecurse nounwind readnone71define 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, %b75  %c.d = select i1 %cmp, i64 %c, i64 %d76; CHECK: r{{[0-9]+}} <<= 3277; CHECK-NEXT: r{{[0-9]+}} s>>= 3278; CHECK: if r{{[0-9]+}} s{{<|>}} r{{[0-9]+}} goto79  ret i64 %c.d80}81 82; Function Attrs: nounwind83define dso_local i32 @foo(i32 %b, i32 %c) local_unnamed_addr #0 {84; CHECK-LABEL: foo:85entry:86  %call = tail call i64 @bar() #287  %conv = trunc i64 %call to i3288  %cmp = icmp ult i32 %conv, 1089; %call comes from function call returning i64 so the high bits will need90; to be cleared.91; CHECK: r{{[0-9]+}} = w{{[0-9]+}}92; CHECK-NOT: r{{[0-9]+}} <<= 3293; CHECK-NOT: r{{[0-9]+}} >>= 3294  %b.c = select i1 %cmp, i32 %b, i32 %c95; CHECK: if r{{[0-9]+}} {{<|>}} {{[0-9]+}} goto96  ret i32 %b.c97}98 99declare dso_local i64 @bar(...) local_unnamed_addr #1100 101; Function Attrs: norecurse nounwind readnone102define dso_local ptr @inc_p(ptr readnone %p, i32 %a) local_unnamed_addr #0 {103; CHECK-LABEL: inc_p:104entry:105  %idx.ext = zext i32 %a to i64106; CHECK: r{{[0-9]+}} = w{{[0-9]+}}107; CHECK-NOT: r{{[0-9]+}} <<= 32108; CHECK-NOT: r{{[0-9]+}} >>= 32109  %add.ptr = getelementptr inbounds i32, ptr %p, i64 %idx.ext110  ret ptr %add.ptr111}112 113define dso_local i32 @test() local_unnamed_addr {114; CHECK-LABEL: test:115entry:116  %call = tail call i32 @helper()117  %cmp = icmp sgt i32 %call, 6118; The shifts can't be optimized out because %call comes from function call119; return i32 so the high bits might be invalid.120; CHECK: r{{[0-9]+}} <<= 32121; CHECK-NEXT: r{{[0-9]+}} s>>= 32122  %cond = zext i1 %cmp to i32123; CHECK: if r{{[0-9]+}} s{{<|>}} {{[0-9]+}} goto124  ret i32 %cond125}126declare dso_local i32 @helper(...) local_unnamed_addr127