|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | +; RUN: opt -S -loop-reduce < %s | FileCheck %s |
| 3 | + |
| 4 | +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 5 | +target triple = "x86_64-unknown-linux-gnu" |
| 6 | + |
| 7 | +declare void @maybe_throws() |
| 8 | +declare void @use1(i1) |
| 9 | + |
| 10 | +define void @is_not_42(i8* %baseptr, i8* %finalptr) local_unnamed_addr align 2 personality i8* undef { |
| 11 | +; CHECK-LABEL: @is_not_42( |
| 12 | +; CHECK-NEXT: preheader: |
| 13 | +; CHECK-NEXT: [[BASEPTR1:%.*]] = ptrtoint i8* [[BASEPTR:%.*]] to i64 |
| 14 | +; CHECK-NEXT: [[TMP0:%.*]] = sub i64 0, [[BASEPTR1]] |
| 15 | +; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* inttoptr (i64 42 to i8*), i64 [[TMP0]] |
| 16 | +; CHECK-NEXT: br label [[HEADER:%.*]] |
| 17 | +; CHECK: header: |
| 18 | +; CHECK-NEXT: [[LSR_IV:%.*]] = phi i8* [ [[SCEVGEP2:%.*]], [[LATCH:%.*]] ], [ [[SCEVGEP]], [[PREHEADER:%.*]] ] |
| 19 | +; CHECK-NEXT: invoke void @maybe_throws() |
| 20 | +; CHECK-NEXT: to label [[LATCH]] unwind label [[LPAD:%.*]] |
| 21 | +; CHECK: lpad: |
| 22 | +; CHECK-NEXT: [[TMP1:%.*]] = landingpad { i8*, i32 } |
| 23 | +; CHECK-NEXT: catch i8* inttoptr (i64 42 to i8*) |
| 24 | +; CHECK-NEXT: [[PTR_IS_NOT_42:%.*]] = icmp ne i8* [[LSR_IV]], null |
| 25 | +; CHECK-NEXT: call void @use1(i1 [[PTR_IS_NOT_42]]) |
| 26 | +; CHECK-NEXT: ret void |
| 27 | +; CHECK: latch: |
| 28 | +; CHECK-NEXT: [[SCEVGEP2]] = getelementptr i8, i8* [[LSR_IV]], i64 -1 |
| 29 | +; CHECK-NEXT: br label [[HEADER]] |
| 30 | +; |
| 31 | +preheader: |
| 32 | + br label %header |
| 33 | + |
| 34 | +header: |
| 35 | + %ptr = phi i8* [ %incptr, %latch ], [ %baseptr, %preheader ] |
| 36 | + invoke void @maybe_throws() to label %latch unwind label %lpad |
| 37 | + |
| 38 | +lpad: |
| 39 | + landingpad { i8*, i32 } catch i8* inttoptr (i64 42 to i8*) |
| 40 | + %ptr_is_not_42 = icmp ne i8* %ptr, inttoptr (i64 42 to i8*) |
| 41 | + call void @use1(i1 %ptr_is_not_42) |
| 42 | + ret void |
| 43 | + |
| 44 | +latch: |
| 45 | + %incptr = getelementptr inbounds i8, i8* %ptr, i64 1 |
| 46 | + br label %header |
| 47 | +} |
0 commit comments