1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=irce -S < %s | FileCheck %s
3 ; RUN: opt -passes='require<branch-prob>,irce' -S < %s | FileCheck %s
5 @array = external global [1528 x i16], align 1
7 ; Make sure we do not crash here.
8 define void @test_01() {
9 ; CHECK-LABEL: @test_01(
11 ; CHECK-NEXT: br label [[CONT48:%.*]]
13 ; CHECK-NEXT: [[A2_0121:%.*]] = phi ptr [ [[ADD_PTR74:%.*]], [[CONT76:%.*]] ], [ @array, [[ENTRY:%.*]] ]
14 ; CHECK-NEXT: [[I41_0119:%.*]] = phi i16 [ [[ADD73:%.*]], [[CONT76]] ], [ 0, [[ENTRY]] ]
15 ; CHECK-NEXT: [[ADD73]] = add nuw nsw i16 [[I41_0119]], 2
16 ; CHECK-NEXT: [[ADD_PTR74]] = getelementptr inbounds i16, ptr [[A2_0121]], i16 2
17 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ult ptr [[A2_0121]], inttoptr (i16 -2 to ptr)
18 ; CHECK-NEXT: br i1 [[TMP0]], label [[CONT76]], label [[HANDLER_POINTER_OVERFLOW75:%.*]]
19 ; CHECK: handler.pointer_overflow75:
20 ; CHECK-NEXT: unreachable
22 ; CHECK-NEXT: [[CMP43:%.*]] = icmp ult i16 [[ADD73]], 16
23 ; CHECK-NEXT: br i1 [[CMP43]], label [[CONT48]], label [[FOR_END77:%.*]]
25 ; CHECK-NEXT: unreachable
30 cont48: ; preds = %cont76, %entry
31 %a2.0121 = phi ptr [ %add.ptr74, %cont76 ], [ @array, %entry ]
32 %i41.0119 = phi i16 [ %add73, %cont76 ], [ 0, %entry ]
33 %add73 = add nuw nsw i16 %i41.0119, 2
34 %add.ptr74 = getelementptr inbounds i16, ptr %a2.0121, i16 2
35 %0 = icmp ult ptr %a2.0121, inttoptr (i16 -2 to ptr)
36 br i1 %0, label %cont76, label %handler.pointer_overflow75
38 handler.pointer_overflow75: ; preds = %cont48
41 cont76: ; preds = %cont48
42 %cmp43 = icmp ult i16 %add73, 16
43 br i1 %cmp43, label %cont48, label %for.end77
45 for.end77: ; preds = %cont76