1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
2 ; RUN: opt -S -passes='require<profile-summary>,function(codegenprepare)' %s -o - | 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"
5 target triple = "x86_64-unknown-linux-gnu"
7 %struct.Blub = type { i8, i8, ptr }
9 @indirectBrPtr = external hidden global ptr
11 define ptr @testFunc(ptr readonly %array, i1 %skip) {
12 ; CHECK-LABEL: define ptr @testFunc(
13 ; CHECK-SAME: ptr readonly [[ARRAY:%.*]], i1 [[SKIP:%.*]]) {
15 ; CHECK-NEXT: br i1 [[SKIP]], label [[LOOPHEADER:%.*]], label [[ENDBLOCK_CLONE:%.*]]
17 ; CHECK-NEXT: [[CURRENTARRAYELEMENT:%.*]] = phi ptr [ [[ARRAY]], [[ENTRY:%.*]] ], [ [[NEXTARRAYELEMENT:%.*]], [[LOOPFOOTER:%.*]] ]
18 ; CHECK-NEXT: [[ELEMENTVALUEPTR:%.*]] = getelementptr inbounds i8, ptr [[CURRENTARRAYELEMENT]], i64 1
19 ; CHECK-NEXT: [[ELEMENTVALUE:%.*]] = load i8, ptr [[ELEMENTVALUEPTR]], align 1
20 ; CHECK-NEXT: indirectbr ptr @indirectBrPtr, [label [[LOOPFOOTER]], label %endBlock]
22 ; CHECK-NEXT: [[ISGOODVALUE:%.*]] = icmp eq i8 [[ELEMENTVALUE]], 0
23 ; CHECK-NEXT: [[NEXTARRAYELEMENT]] = getelementptr inbounds [[STRUCT_BLUB:%.*]], ptr [[CURRENTARRAYELEMENT]], i64 1
24 ; CHECK-NEXT: br i1 [[ISGOODVALUE]], label [[LOOPHEADER]], label [[ENDBLOCK_CLONE]]
26 ; CHECK-NEXT: br label [[DOTSPLIT:%.*]]
28 ; CHECK-NEXT: [[MERGE:%.*]] = phi ptr [ [[ELEMENTVALUEPTR]], [[ENDBLOCK:%.*]] ], [ [[RETVAL_CLONE:%.*]], [[ENDBLOCK_CLONE]] ]
29 ; CHECK-NEXT: ret ptr [[MERGE]]
30 ; CHECK: endBlock.clone:
31 ; CHECK-NEXT: [[RETVAL_CLONE]] = phi ptr [ [[ARRAY]], [[ENTRY]] ], [ [[ELEMENTVALUEPTR]], [[LOOPFOOTER]] ]
32 ; CHECK-NEXT: br label [[DOTSPLIT]]
35 br i1 %skip, label %loopHeader, label %endBlock
38 %currentArrayElement = phi ptr [ %array, %entry ], [ %nextArrayElement, %loopFooter ]
39 %elementValuePtr = getelementptr inbounds i8, ptr %currentArrayElement, i64 1
40 %elementValue = load i8, ptr %elementValuePtr, align 1
41 indirectbr ptr @indirectBrPtr, [label %loopFooter, label %endBlock]
44 %isGoodValue = icmp eq i8 %elementValue, 0
45 %nextArrayElement = getelementptr inbounds %struct.Blub, ptr %currentArrayElement, i64 1
46 br i1 %isGoodValue, label %loopHeader, label %endBlock
49 %retVal = phi ptr [ %array, %entry ], [ %elementValuePtr, %loopFooter ], [ %elementValuePtr, %loopHeader ]