xref: /llvm-project/llvm/test/Transforms/LoopBoundSplit/bug51766.ll (revision dec3a92eee3e3e7e43c61e54855e32665ea743a9)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -passes=loop-bound-split -S < %s | FileCheck %s
3
4; LoopBoundSplit pass should fail to split this test's loop because the split
5; condition is false in first iteration of the loop.
6
7define i16 @main(i16 %qqq) {
8; CHECK-LABEL: @main(
9; CHECK-NEXT:  entry:
10; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
11; CHECK:       for.body:
12; CHECK-NEXT:    [[T0:%.*]] = phi i16 [ 0, [[ENTRY:%.*]] ], [ [[T8:%.*]], [[CONT19:%.*]] ]
13; CHECK-NEXT:    [[T1:%.*]] = shl nuw nsw i16 [[T0]], 1
14; CHECK-NEXT:    [[T2:%.*]] = add i16 [[T1]], [[QQQ:%.*]]
15; CHECK-NEXT:    [[DOTNOT9:%.*]] = icmp ult i16 [[T2]], [[QQQ]]
16; CHECK-NEXT:    br i1 [[DOTNOT9]], label [[HANDLER_POINTER_OVERFLOW:%.*]], label [[CONT15_CRITEDGE:%.*]]
17; CHECK:       handler.pointer_overflow:
18; CHECK-NEXT:    call void @__ubsan_handle_pointer_overflow()
19; CHECK-NEXT:    br label [[CONT19]]
20; CHECK:       cont15.critedge:
21; CHECK-NEXT:    br label [[CONT19]]
22; CHECK:       cont19:
23; CHECK-NEXT:    [[T8]] = add nuw nsw i16 [[T0]], 1
24; CHECK-NEXT:    [[EXITCOND_NOT:%.*]] = icmp eq i16 [[T8]], 3
25; CHECK-NEXT:    br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY]]
26; CHECK:       for.cond.cleanup:
27; CHECK-NEXT:    ret i16 0
28;
29entry:
30  br label %for.body
31
32for.body:
33  %t0 = phi i16 [ 0, %entry ], [ %t8, %cont19 ]
34  %t1 = shl nuw nsw i16 %t0, 1
35  %t2 = add i16 %t1, %qqq
36  %.not9 = icmp ult i16 %t2, %qqq
37  br i1 %.not9, label %handler.pointer_overflow, label %cont15.critedge
38
39handler.pointer_overflow:
40  call void @__ubsan_handle_pointer_overflow()
41  br label %cont19
42
43cont15.critedge:
44  br label %cont19
45
46cont19:
47  %t8 = add nuw nsw i16 %t0, 1
48  %exitcond.not = icmp eq i16 %t8, 3
49  br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
50
51for.cond.cleanup:
52  ret i16 0
53}
54
55declare dso_local void @__ubsan_handle_pointer_overflow()
56