1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -S -passes=inline < %s | FileCheck %s
4 ; Make sure the loop condition is not incorrectly simplified during inlinig.
5 define internal i32 @pow(i32 %Base, i32 %Power) {
7 %IsZero = icmp eq i32 %Power, 0
8 br i1 %IsZero, label %while.end, label %while.body
11 %Val = phi i32 [ %mul, %while.body ], [ 1, %entry ]
12 %Power.Phi = phi i32 [ %dec, %while.body ], [ %Power, %entry ]
13 %dec = add i32 %Power.Phi, -1
14 %mul = mul i32 %Val, %Base
15 %tobool.not = icmp eq i32 %dec, 0
16 br i1 %tobool.not, label %while.end, label %while.body
19 %Res = phi i32 [ 1, %entry ], [ %mul, %while.body ]
23 define i32 @caller(i32 %Base, i32 %Power) {
24 ; CHECK-LABEL: define i32 @caller
25 ; CHECK-SAME: (i32 [[BASE:%.*]], i32 [[POWER:%.*]]) {
26 ; CHECK-NEXT: [[ISZERO_I:%.*]] = icmp eq i32 [[POWER]], 0
27 ; CHECK-NEXT: br i1 [[ISZERO_I]], label [[POW_EXIT:%.*]], label [[WHILE_BODY_I:%.*]]
28 ; CHECK: while.body.i:
29 ; CHECK-NEXT: [[VAL_I:%.*]] = phi i32 [ [[MUL_I:%.*]], [[WHILE_BODY_I]] ], [ 1, [[TMP0:%.*]] ]
30 ; CHECK-NEXT: [[POWER_PHI_I:%.*]] = phi i32 [ [[DEC_I:%.*]], [[WHILE_BODY_I]] ], [ [[POWER]], [[TMP0]] ]
31 ; CHECK-NEXT: [[DEC_I]] = add i32 [[POWER_PHI_I]], -1
32 ; CHECK-NEXT: [[MUL_I]] = mul i32 [[VAL_I]], [[BASE]]
33 ; CHECK-NEXT: [[TOBOOL_NOT_I:%.*]] = icmp eq i32 [[DEC_I]], 0
34 ; CHECK-NEXT: br i1 [[TOBOOL_NOT_I]], label [[POW_EXIT]], label [[WHILE_BODY_I]]
36 ; CHECK-NEXT: [[RES_I:%.*]] = phi i32 [ 1, [[TMP0]] ], [ [[MUL_I]], [[WHILE_BODY_I]] ]
37 ; CHECK-NEXT: ret i32 [[RES_I]]
39 %res = call i32 @pow(i32 %Base, i32 %Power)