54 lines · plain
1; RUN: llc -O2 -mtriple=bpfel -mcpu=v2 -mattr=+alu32 < %s | FileCheck %s2;3; For the below example, two phi node in the loop may depend on4; each other. So implementation must handle recursion properly.5;6; int test(unsigned long a, unsigned long b, unsigned long c) {7; int val = 0;8;9; #pragma clang loop unroll(disable)10; for (long i = 0; i < 100; i++) {11; if (a > b)12; val = 1;13; a += b;14; if (b > c)15; val = 1;16; b += c;17; }18;19; return val == 0 ? 1 : 0;20; }21 22 23define dso_local i32 @test(i64 %a, i64 %b, i64 %c) local_unnamed_addr {24entry:25 br label %for.body26 27for.cond.cleanup: ; preds = %for.body28 %cmp6 = icmp eq i32 %val.2, 029 %cond = zext i1 %cmp6 to i3230 ret i32 %cond31 32for.body: ; preds = %for.body, %entry33 %i.018 = phi i64 [ 0, %entry ], [ %inc, %for.body ]34 %val.017 = phi i32 [ 0, %entry ], [ %val.2, %for.body ]35 %a.addr.016 = phi i64 [ %a, %entry ], [ %add, %for.body ]36 %b.addr.015 = phi i64 [ %b, %entry ], [ %add5, %for.body ]37 %cmp1 = icmp ugt i64 %a.addr.016, %b.addr.01538 %add = add i64 %a.addr.016, %b.addr.01539 %cmp2 = icmp ugt i64 %b.addr.015, %c40 %0 = or i1 %cmp2, %cmp141 %val.2 = select i1 %0, i32 1, i32 %val.01742 %add5 = add i64 %b.addr.015, %c43 %inc = add nuw nsw i64 %i.018, 144 %exitcond = icmp eq i64 %inc, 10045 br i1 %exitcond, label %for.cond.cleanup, label %for.body, !llvm.loop !246}47; CHECK: [[VAL:r[0-9]+]] = w{{[0-9]+}}48; CHECK-NOT: [[VAL:r[0-9]+]] <<= 3249; CHECK-NOT: [[VAL]] >>= 3250; CHECK: if [[VAL]] == 0 goto51 52!2 = distinct !{!2, !3}53!3 = !{!"llvm.loop.unroll.disable"}54