1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -loop-reduce < %s | FileCheck %s
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6 define void @test(ptr %p.base, i8 %x) {
9 ; CHECK-NEXT: switch i8 [[X:%.*]], label [[WHILE_END:%.*]] [
10 ; CHECK-NEXT: i8 10, label [[WHILE_BODY_PREHEADER:%.*]]
11 ; CHECK-NEXT: i8 20, label [[WHILE_BODY_PREHEADER]]
13 ; CHECK: while.body.preheader:
14 ; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, ptr [[P_BASE:%.*]], i64 1
15 ; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
17 ; CHECK-NEXT: [[LSR_IV:%.*]] = phi ptr [ [[SCEVGEP1:%.*]], [[WHILE_BODY_BACKEDGE:%.*]] ], [ [[SCEVGEP]], [[WHILE_BODY_PREHEADER]] ]
18 ; CHECK-NEXT: [[Y:%.*]] = load i8, ptr [[LSR_IV]], align 1
19 ; CHECK-NEXT: switch i8 [[Y]], label [[WHILE_END_LOOPEXIT:%.*]] [
20 ; CHECK-NEXT: i8 10, label [[WHILE_BODY_BACKEDGE]]
21 ; CHECK-NEXT: i8 20, label [[WHILE_BODY_BACKEDGE]]
23 ; CHECK: while.body.backedge:
24 ; CHECK-NEXT: [[SCEVGEP1]] = getelementptr i8, ptr [[LSR_IV]], i64 1
25 ; CHECK-NEXT: br label [[WHILE_BODY]]
26 ; CHECK: while.end.loopexit:
27 ; CHECK-NEXT: br label [[WHILE_END]]
29 ; CHECK-NEXT: ret void
32 switch i8 %x, label %while.end [
33 i8 10, label %while.body
34 i8 20, label %while.body
38 %p = phi ptr [ %p.inc, %while.body ], [ %p.inc, %while.body ], [ %p.base, %entry ], [ %p.base, %entry ]
39 %p.inc = getelementptr inbounds i8, ptr %p, i64 1
40 %y = load i8, ptr %p.inc, align 1
41 switch i8 %y, label %while.end [
42 i8 10, label %while.body
43 i8 20, label %while.body