1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -S -passes=loop-reduce -mtriple=riscv64-unknown-linux-gnu < %s | FileCheck %s
4 define void @test(ptr %p, i8 %arg, i32 %start) {
5 ; CHECK-LABEL: define void @test(
6 ; CHECK-SAME: ptr [[P:%.*]], i8 [[ARG:%.*]], i32 [[START:%.*]]) {
8 ; CHECK-NEXT: [[CONV:%.*]] = zext i8 [[ARG]] to i32
9 ; CHECK-NEXT: [[SHR:%.*]] = lshr i32 [[CONV]], 1
10 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[START]], [[SHR]]
11 ; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[TMP0]], 1
12 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
14 ; CHECK-NEXT: [[ADD810:%.*]] = phi i32 [ [[START]], [[ENTRY:%.*]] ], [ [[ADD:%.*]], [[FOR_BODY]] ]
15 ; CHECK-NEXT: [[IDXPROM2:%.*]] = zext i32 [[ADD810]] to i64
16 ; CHECK-NEXT: [[ARRAYIDX3:%.*]] = getelementptr i8, ptr [[P]], i64 [[IDXPROM2]]
17 ; CHECK-NEXT: [[V:%.*]] = load i8, ptr [[ARRAYIDX3]], align 1
18 ; CHECK-NEXT: [[ADD]] = add i32 [[ADD810]], 1
19 ; CHECK-NEXT: [[LSR_FOLD_TERM_COND_REPLACED_TERM_COND:%.*]] = icmp eq i32 [[ADD]], [[TMP1]]
20 ; CHECK-NEXT: br i1 [[LSR_FOLD_TERM_COND_REPLACED_TERM_COND]], label [[EXIT:%.*]], label [[FOR_BODY]]
22 ; CHECK-NEXT: ret void
25 %conv = zext i8 %arg to i32
26 %shr = lshr i32 %conv, 1
27 %wide.trip.count = zext nneg i32 %shr to i64
31 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
32 %add810 = phi i32 [ %start, %entry ], [ %add, %for.body ]
33 %idxprom2 = zext i32 %add810 to i64
34 %arrayidx3 = getelementptr i8, ptr %p, i64 %idxprom2
35 %v = load i8, ptr %arrayidx3, align 1
36 %add = add i32 %add810, 1
37 %indvars.iv.next = add i64 %indvars.iv, 1
38 %exitcond.not = icmp eq i64 %indvars.iv, %wide.trip.count
39 br i1 %exitcond.not, label %exit, label %for.body