1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt %s -S -mtriple=riscv64 -passes=loop-unroll | FileCheck %s
4 ; Demonstrate handling of invalid costs in LoopUnroll. This test uses
5 ; scalable vectors on RISCV w/o +V to create a situation where a construct
6 ; can not be lowered, and is thus invalid regardless of what the target
7 ; does or does not implement in terms of a cost model.
9 target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
10 target triple = "riscv64-unknown-unknown"
12 define void @invalid(ptr %p) nounwind ssp {
13 ; CHECK-LABEL: @invalid(
15 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
17 ; CHECK-NEXT: [[I_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
18 ; CHECK-NEXT: [[A:%.*]] = load <vscale x 1 x i8>, ptr [[P:%.*]], align 1
19 ; CHECK-NEXT: [[B:%.*]] = add <vscale x 1 x i8> [[A]], [[A]]
20 ; CHECK-NEXT: store <vscale x 1 x i8> [[B]], ptr [[P]], align 1
21 ; CHECK-NEXT: [[INC]] = add nsw i32 [[I_0]], 1
22 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I_0]], 10
23 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]]
25 ; CHECK-NEXT: ret void
30 for.body: ; preds = %for.body, %entry
31 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
32 %a = load <vscale x 1 x i8>, ptr %p
33 %b = add <vscale x 1 x i8> %a, %a
34 store <vscale x 1 x i8> %b, ptr %p
35 %inc = add nsw i32 %i.0, 1
36 %cmp = icmp slt i32 %i.0, 10
37 br i1 %cmp, label %for.body, label %for.end
39 for.end: ; preds = %for.body