| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s |
| |
| target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| |
| |
| declare void @use(ptr) |
| declare i1 @cond() |
| |
| define void @test_monotonic_ptr_iv_inc_1_eq_to_uge(ptr %start) { |
| ; CHECK-LABEL: @test_monotonic_ptr_iv_inc_1_eq_to_uge( |
| ; CHECK-NEXT: loop.ph: |
| ; CHECK-NEXT: [[UPPER:%.*]] = getelementptr inbounds i32, ptr [[START:%.*]], i16 10 |
| ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]] |
| ; CHECK: loop.header: |
| ; CHECK-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], [[LOOP_PH:%.*]] ], [ [[PTR_IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ] |
| ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] |
| ; CHECK: for.body: |
| ; CHECK-NEXT: [[AND:%.*]] = and i1 true, true |
| ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] |
| ; CHECK: loop.latch: |
| ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) |
| ; CHECK-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i32, ptr [[PTR_IV]], i16 1 |
| ; CHECK-NEXT: br label [[LOOP_HEADER]] |
| ; CHECK: exit: |
| ; CHECK-NEXT: ret void |
| ; |
| loop.ph: |
| %upper = getelementptr inbounds i32, ptr %start, i16 10 |
| br label %loop.header |
| |
| loop.header: |
| %ptr.iv = phi ptr [ %start, %loop.ph ], [ %ptr.iv.next, %loop.latch ] |
| %c = icmp eq ptr %ptr.iv, %upper |
| br i1 %c, label %exit, label %for.body |
| |
| for.body: |
| %t.1 = icmp uge ptr %ptr.iv, %start |
| %t.2 = icmp ult ptr %ptr.iv, %upper |
| %and = and i1 %t.1, %t.2 |
| br i1 %and, label %loop.latch, label %exit |
| |
| loop.latch: |
| call void @use(ptr %ptr.iv) |
| %ptr.iv.next = getelementptr inbounds i32, ptr %ptr.iv, i16 1 |
| br label %loop.header |
| |
| exit: |
| ret void |
| } |
| |
| define void @test_monotonic_ptr_iv_inc_1_upper_is_multiple_1(ptr %start) { |
| ; CHECK-LABEL: @test_monotonic_ptr_iv_inc_1_upper_is_multiple_1( |
| ; CHECK-NEXT: loop.ph: |
| ; CHECK-NEXT: [[UPPER:%.*]] = getelementptr inbounds i8, ptr [[START:%.*]], i16 15 |
| ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]] |
| ; CHECK: loop.header: |
| ; CHECK-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], [[LOOP_PH:%.*]] ], [ [[PTR_IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ] |
| ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] |
| ; CHECK: for.body: |
| ; CHECK-NEXT: [[AND:%.*]] = and i1 true, true |
| ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] |
| ; CHECK: loop.latch: |
| ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) |
| ; CHECK-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i8, ptr [[PTR_IV]], i16 1 |
| ; CHECK-NEXT: br label [[LOOP_HEADER]] |
| ; CHECK: exit: |
| ; CHECK-NEXT: ret void |
| ; |
| loop.ph: |
| %upper = getelementptr inbounds i8, ptr %start, i16 15 |
| br label %loop.header |
| |
| loop.header: |
| %ptr.iv = phi ptr [ %start, %loop.ph ], [ %ptr.iv.next, %loop.latch ] |
| %c = icmp eq ptr %ptr.iv, %upper |
| br i1 %c, label %exit, label %for.body |
| |
| for.body: |
| %t.1 = icmp uge ptr %ptr.iv, %start |
| %t.2 = icmp ult ptr %ptr.iv, %upper |
| %and = and i1 %t.1, %t.2 |
| br i1 %and, label %loop.latch, label %exit |
| |
| loop.latch: |
| call void @use(ptr %ptr.iv) |
| %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i16 1 |
| br label %loop.header |
| |
| exit: |
| ret void |
| } |
| |
| define void @test_monotonic_ptr_iv_inc_1_upper_is_multiple_2(ptr %start) { |
| ; CHECK-LABEL: @test_monotonic_ptr_iv_inc_1_upper_is_multiple_2( |
| ; CHECK-NEXT: loop.ph: |
| ; CHECK-NEXT: [[UPPER:%.*]] = getelementptr inbounds i8, ptr [[START:%.*]], i16 16 |
| ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]] |
| ; CHECK: loop.header: |
| ; CHECK-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], [[LOOP_PH:%.*]] ], [ [[PTR_IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ] |
| ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] |
| ; CHECK: for.body: |
| ; CHECK-NEXT: [[AND:%.*]] = and i1 true, true |
| ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] |
| ; CHECK: loop.latch: |
| ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) |
| ; CHECK-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i16, ptr [[PTR_IV]], i16 1 |
| ; CHECK-NEXT: br label [[LOOP_HEADER]] |
| ; CHECK: exit: |
| ; CHECK-NEXT: ret void |
| ; |
| loop.ph: |
| %upper = getelementptr inbounds i8, ptr %start, i16 16 |
| br label %loop.header |
| |
| loop.header: |
| %ptr.iv = phi ptr [ %start, %loop.ph ], [ %ptr.iv.next, %loop.latch ] |
| %c = icmp eq ptr %ptr.iv, %upper |
| br i1 %c, label %exit, label %for.body |
| |
| for.body: |
| %t.1 = icmp uge ptr %ptr.iv, %start |
| %t.2 = icmp ult ptr %ptr.iv, %upper |
| %and = and i1 %t.1, %t.2 |
| br i1 %and, label %loop.latch, label %exit |
| |
| loop.latch: |
| call void @use(ptr %ptr.iv) |
| %ptr.iv.next = getelementptr inbounds i16, ptr %ptr.iv, i16 1 |
| br label %loop.header |
| |
| exit: |
| ret void |
| } |
| |
| define void @test_monotonic_ptr_iv_inc_upper_is_not_multiple_1(ptr %start) { |
| ; CHECK-LABEL: @test_monotonic_ptr_iv_inc_upper_is_not_multiple_1( |
| ; CHECK-NEXT: loop.ph: |
| ; CHECK-NEXT: [[UPPER:%.*]] = getelementptr inbounds i8, ptr [[START:%.*]], i16 15 |
| ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]] |
| ; CHECK: loop.header: |
| ; CHECK-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], [[LOOP_PH:%.*]] ], [ [[PTR_IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ] |
| ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] |
| ; CHECK: for.body: |
| ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] |
| ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] |
| ; CHECK: loop.latch: |
| ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) |
| ; CHECK-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i32, ptr [[PTR_IV]], i16 1 |
| ; CHECK-NEXT: br label [[LOOP_HEADER]] |
| ; CHECK: exit: |
| ; CHECK-NEXT: ret void |
| ; |
| loop.ph: |
| %upper = getelementptr inbounds i8, ptr %start, i16 15 |
| br label %loop.header |
| |
| loop.header: |
| %ptr.iv = phi ptr [ %start, %loop.ph ], [ %ptr.iv.next, %loop.latch ] |
| %c = icmp eq ptr %ptr.iv, %upper |
| br i1 %c, label %exit, label %for.body |
| |
| for.body: |
| %t.1 = icmp uge ptr %ptr.iv, %start |
| %t.2 = icmp ult ptr %ptr.iv, %upper |
| %and = and i1 %t.1, %t.2 |
| br i1 %and, label %loop.latch, label %exit |
| |
| loop.latch: |
| call void @use(ptr %ptr.iv) |
| %ptr.iv.next = getelementptr inbounds i32, ptr %ptr.iv, i16 1 |
| br label %loop.header |
| |
| exit: |
| ret void |
| } |
| |
| define void @test_monotonic_ptr_iv_inc_upper_is_not_multiple_2(ptr %start) { |
| ; CHECK-LABEL: @test_monotonic_ptr_iv_inc_upper_is_not_multiple_2( |
| ; CHECK-NEXT: loop.ph: |
| ; CHECK-NEXT: [[UPPER:%.*]] = getelementptr inbounds i8, ptr [[START:%.*]], i16 15 |
| ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]] |
| ; CHECK: loop.header: |
| ; CHECK-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], [[LOOP_PH:%.*]] ], [ [[PTR_IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ] |
| ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] |
| ; CHECK: for.body: |
| ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] |
| ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] |
| ; CHECK: loop.latch: |
| ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) |
| ; CHECK-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i32, ptr [[PTR_IV]], i16 1 |
| ; CHECK-NEXT: br label [[LOOP_HEADER]] |
| ; CHECK: exit: |
| ; CHECK-NEXT: ret void |
| ; |
| loop.ph: |
| %upper = getelementptr inbounds i8, ptr %start, i16 15 |
| br label %loop.header |
| |
| loop.header: |
| %ptr.iv = phi ptr [ %start, %loop.ph ], [ %ptr.iv.next, %loop.latch ] |
| %c = icmp eq ptr %ptr.iv, %upper |
| br i1 %c, label %exit, label %for.body |
| |
| for.body: |
| %t.1 = icmp uge ptr %ptr.iv, %start |
| %t.2 = icmp ult ptr %ptr.iv, %upper |
| %and = and i1 %t.1, %t.2 |
| br i1 %and, label %loop.latch, label %exit |
| |
| loop.latch: |
| call void @use(ptr %ptr.iv) |
| %ptr.iv.next = getelementptr inbounds i32, ptr %ptr.iv, i16 1 |
| br label %loop.header |
| |
| exit: |
| ret void |
| } |
| |
| define void @test_monotonic_ptr_iv_inc_1_upper_is_multiple_with_early_exit_1(ptr %start) { |
| ; CHECK-LABEL: @test_monotonic_ptr_iv_inc_1_upper_is_multiple_with_early_exit_1( |
| ; CHECK-NEXT: loop.ph: |
| ; CHECK-NEXT: [[UPPER:%.*]] = getelementptr inbounds i8, ptr [[START:%.*]], i16 10 |
| ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]] |
| ; CHECK: loop.header: |
| ; CHECK-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], [[LOOP_PH:%.*]] ], [ [[PTR_IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ] |
| ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] |
| ; CHECK: for.body: |
| ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() |
| ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] |
| ; CHECK: loop.next: |
| ; CHECK-NEXT: [[AND:%.*]] = and i1 true, true |
| ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] |
| ; CHECK: loop.latch: |
| ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) |
| ; CHECK-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i8, ptr [[PTR_IV]], i16 1 |
| ; CHECK-NEXT: br label [[LOOP_HEADER]] |
| ; CHECK: exit: |
| ; CHECK-NEXT: ret void |
| ; |
| loop.ph: |
| %upper = getelementptr inbounds i8, ptr %start, i16 10 |
| br label %loop.header |
| |
| loop.header: |
| %ptr.iv = phi ptr [ %start, %loop.ph ], [ %ptr.iv.next, %loop.latch ] |
| %c = icmp eq ptr %ptr.iv, %upper |
| br i1 %c, label %exit, label %for.body |
| |
| for.body: |
| %c.1 = call i1 @cond() |
| br i1 %c.1, label %loop.next, label %exit |
| |
| loop.next: |
| %t.1 = icmp uge ptr %ptr.iv, %start |
| %t.2 = icmp ult ptr %ptr.iv, %upper |
| %and = and i1 %t.1, %t.2 |
| br i1 %and, label %loop.latch, label %exit |
| |
| loop.latch: |
| call void @use(ptr %ptr.iv) |
| %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i16 1 |
| br label %loop.header |
| |
| exit: |
| ret void |
| } |
| |
| define void @test_monotonic_ptr_iv_inc_1_upper_is_multiple_with_early_exit_2(ptr %start) { |
| ; CHECK-LABEL: @test_monotonic_ptr_iv_inc_1_upper_is_multiple_with_early_exit_2( |
| ; CHECK-NEXT: loop.ph: |
| ; CHECK-NEXT: [[UPPER:%.*]] = getelementptr inbounds i8, ptr [[START:%.*]], i16 10 |
| ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]] |
| ; CHECK: loop.header: |
| ; CHECK-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], [[LOOP_PH:%.*]] ], [ [[PTR_IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ] |
| ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] |
| ; CHECK: for.body: |
| ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() |
| ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] |
| ; CHECK: loop.next: |
| ; CHECK-NEXT: [[AND:%.*]] = and i1 true, true |
| ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] |
| ; CHECK: loop.latch: |
| ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) |
| ; CHECK-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i16, ptr [[PTR_IV]], i16 1 |
| ; CHECK-NEXT: br label [[LOOP_HEADER]] |
| ; CHECK: exit: |
| ; CHECK-NEXT: ret void |
| ; |
| loop.ph: |
| %upper = getelementptr inbounds i8, ptr %start, i16 10 |
| br label %loop.header |
| |
| loop.header: |
| %ptr.iv = phi ptr [ %start, %loop.ph ], [ %ptr.iv.next, %loop.latch ] |
| %c = icmp eq ptr %ptr.iv, %upper |
| br i1 %c, label %exit, label %for.body |
| |
| for.body: |
| %c.1 = call i1 @cond() |
| br i1 %c.1, label %loop.next, label %exit |
| |
| loop.next: |
| %t.1 = icmp uge ptr %ptr.iv, %start |
| %t.2 = icmp ult ptr %ptr.iv, %upper |
| %and = and i1 %t.1, %t.2 |
| br i1 %and, label %loop.latch, label %exit |
| |
| loop.latch: |
| call void @use(ptr %ptr.iv) |
| %ptr.iv.next = getelementptr inbounds i16, ptr %ptr.iv, i16 1 |
| br label %loop.header |
| |
| exit: |
| ret void |
| } |
| |
| define void @test_monotonic_ptr_iv_inc_1_upper_is_multiple_with_early_exit_3(ptr %start) { |
| ; CHECK-LABEL: @test_monotonic_ptr_iv_inc_1_upper_is_multiple_with_early_exit_3( |
| ; CHECK-NEXT: loop.ph: |
| ; CHECK-NEXT: [[UPPER:%.*]] = getelementptr inbounds i16, ptr [[START:%.*]], i16 16 |
| ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]] |
| ; CHECK: loop.header: |
| ; CHECK-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], [[LOOP_PH:%.*]] ], [ [[PTR_IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ] |
| ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] |
| ; CHECK: for.body: |
| ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() |
| ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] |
| ; CHECK: loop.next: |
| ; CHECK-NEXT: [[AND:%.*]] = and i1 true, true |
| ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] |
| ; CHECK: loop.latch: |
| ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) |
| ; CHECK-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i32, ptr [[PTR_IV]], i16 1 |
| ; CHECK-NEXT: br label [[LOOP_HEADER]] |
| ; CHECK: exit: |
| ; CHECK-NEXT: ret void |
| ; |
| loop.ph: |
| %upper = getelementptr inbounds i16, ptr %start, i16 16 |
| br label %loop.header |
| |
| loop.header: |
| %ptr.iv = phi ptr [ %start, %loop.ph ], [ %ptr.iv.next, %loop.latch ] |
| %c = icmp eq ptr %ptr.iv, %upper |
| br i1 %c, label %exit, label %for.body |
| |
| for.body: |
| %c.1 = call i1 @cond() |
| br i1 %c.1, label %loop.next, label %exit |
| |
| loop.next: |
| %t.1 = icmp uge ptr %ptr.iv, %start |
| %t.2 = icmp ult ptr %ptr.iv, %upper |
| %and = and i1 %t.1, %t.2 |
| br i1 %and, label %loop.latch, label %exit |
| |
| loop.latch: |
| call void @use(ptr %ptr.iv) |
| %ptr.iv.next = getelementptr inbounds i32, ptr %ptr.iv, i16 1 |
| br label %loop.header |
| |
| exit: |
| ret void |
| } |
| |
| define void @test_monotonic_ptr_iv_inc_1_upper_is_no_multiple_with_early_exit_1(ptr %start) { |
| ; CHECK-LABEL: @test_monotonic_ptr_iv_inc_1_upper_is_no_multiple_with_early_exit_1( |
| ; CHECK-NEXT: loop.ph: |
| ; CHECK-NEXT: [[UPPER:%.*]] = getelementptr inbounds i8, ptr [[START:%.*]], i16 10 |
| ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]] |
| ; CHECK: loop.header: |
| ; CHECK-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], [[LOOP_PH:%.*]] ], [ [[PTR_IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ] |
| ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] |
| ; CHECK: for.body: |
| ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() |
| ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] |
| ; CHECK: loop.next: |
| ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] |
| ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] |
| ; CHECK: loop.latch: |
| ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) |
| ; CHECK-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i32, ptr [[PTR_IV]], i16 1 |
| ; CHECK-NEXT: br label [[LOOP_HEADER]] |
| ; CHECK: exit: |
| ; CHECK-NEXT: ret void |
| ; |
| loop.ph: |
| %upper = getelementptr inbounds i8, ptr %start, i16 10 |
| br label %loop.header |
| |
| loop.header: |
| %ptr.iv = phi ptr [ %start, %loop.ph ], [ %ptr.iv.next, %loop.latch ] |
| %c = icmp eq ptr %ptr.iv, %upper |
| br i1 %c, label %exit, label %for.body |
| |
| for.body: |
| %c.1 = call i1 @cond() |
| br i1 %c.1, label %loop.next, label %exit |
| |
| loop.next: |
| %t.1 = icmp uge ptr %ptr.iv, %start |
| %t.2 = icmp ult ptr %ptr.iv, %upper |
| %and = and i1 %t.1, %t.2 |
| br i1 %and, label %loop.latch, label %exit |
| |
| loop.latch: |
| call void @use(ptr %ptr.iv) |
| %ptr.iv.next = getelementptr inbounds i32, ptr %ptr.iv, i16 1 |
| br label %loop.header |
| |
| exit: |
| ret void |
| } |
| |
| define void @test_monotonic_ptr_iv_inc_1_upper_is_no_multiple_with_early_exit_2(ptr %start) { |
| ; CHECK-LABEL: @test_monotonic_ptr_iv_inc_1_upper_is_no_multiple_with_early_exit_2( |
| ; CHECK-NEXT: loop.ph: |
| ; CHECK-NEXT: [[UPPER:%.*]] = getelementptr inbounds i8, ptr [[START:%.*]], i16 11 |
| ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]] |
| ; CHECK: loop.header: |
| ; CHECK-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], [[LOOP_PH:%.*]] ], [ [[PTR_IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ] |
| ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] |
| ; CHECK: for.body: |
| ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() |
| ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] |
| ; CHECK: loop.next: |
| ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] |
| ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] |
| ; CHECK: loop.latch: |
| ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) |
| ; CHECK-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i16, ptr [[PTR_IV]], i16 1 |
| ; CHECK-NEXT: br label [[LOOP_HEADER]] |
| ; CHECK: exit: |
| ; CHECK-NEXT: ret void |
| ; |
| loop.ph: |
| %upper = getelementptr inbounds i8, ptr %start, i16 11 |
| br label %loop.header |
| |
| loop.header: |
| %ptr.iv = phi ptr [ %start, %loop.ph ], [ %ptr.iv.next, %loop.latch ] |
| %c = icmp eq ptr %ptr.iv, %upper |
| br i1 %c, label %exit, label %for.body |
| |
| for.body: |
| %c.1 = call i1 @cond() |
| br i1 %c.1, label %loop.next, label %exit |
| |
| loop.next: |
| %t.1 = icmp uge ptr %ptr.iv, %start |
| %t.2 = icmp ult ptr %ptr.iv, %upper |
| %and = and i1 %t.1, %t.2 |
| br i1 %and, label %loop.latch, label %exit |
| |
| loop.latch: |
| call void @use(ptr %ptr.iv) |
| %ptr.iv.next = getelementptr inbounds i16, ptr %ptr.iv, i16 1 |
| br label %loop.header |
| |
| exit: |
| ret void |
| } |
| |
| define void @test_monotonic_ptr_iv_inc_1_upper_is_no_multiple_with_early_exit_3(ptr %start) { |
| ; CHECK-LABEL: @test_monotonic_ptr_iv_inc_1_upper_is_no_multiple_with_early_exit_3( |
| ; CHECK-NEXT: loop.ph: |
| ; CHECK-NEXT: [[UPPER:%.*]] = getelementptr inbounds i16, ptr [[START:%.*]], i16 9 |
| ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]] |
| ; CHECK: loop.header: |
| ; CHECK-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], [[LOOP_PH:%.*]] ], [ [[PTR_IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ] |
| ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] |
| ; CHECK: for.body: |
| ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() |
| ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] |
| ; CHECK: loop.next: |
| ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] |
| ; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] |
| ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] |
| ; CHECK: loop.latch: |
| ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) |
| ; CHECK-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i32, ptr [[PTR_IV]], i16 1 |
| ; CHECK-NEXT: br label [[LOOP_HEADER]] |
| ; CHECK: exit: |
| ; CHECK-NEXT: ret void |
| ; |
| loop.ph: |
| %upper = getelementptr inbounds i16, ptr %start, i16 9 |
| br label %loop.header |
| |
| loop.header: |
| %ptr.iv = phi ptr [ %start, %loop.ph ], [ %ptr.iv.next, %loop.latch ] |
| %c = icmp eq ptr %ptr.iv, %upper |
| br i1 %c, label %exit, label %for.body |
| |
| for.body: |
| %c.1 = call i1 @cond() |
| br i1 %c.1, label %loop.next, label %exit |
| |
| loop.next: |
| %t.1 = icmp uge ptr %ptr.iv, %start |
| %t.2 = icmp ult ptr %ptr.iv, %upper |
| %and = and i1 %t.1, %t.2 |
| br i1 %and, label %loop.latch, label %exit |
| |
| loop.latch: |
| call void @use(ptr %ptr.iv) |
| %ptr.iv.next = getelementptr inbounds i32, ptr %ptr.iv, i16 1 |
| br label %loop.header |
| |
| exit: |
| ret void |
| } |