1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc -mtriple=riscv64 -mcpu=sifive-p670 -O3 -verify-machineinstrs -riscv-enable-pipeliner=false < %s \
3 ; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-NOT-PIPELINED
4 ; RUN: llc -mtriple=riscv64 -mcpu=sifive-p670 -O3 -verify-machineinstrs -riscv-enable-pipeliner=true < %s \
5 ; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-PIPELINED
7 ; We shouldn't pipeline this loop as one operand of branch is a PHI.
8 define i32 @test_phi() {
9 ; CHECK-LABEL: test_phi:
10 ; CHECK: # %bb.0: # %entry
11 ; CHECK-NEXT: li a0, 0
12 ; CHECK-NEXT: .LBB0_1: # %for.body
13 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
14 ; CHECK-NEXT: mv a1, a0
15 ; CHECK-NEXT: li a0, 1
16 ; CHECK-NEXT: sh a0, 0(zero)
17 ; CHECK-NEXT: bnez a1, .LBB0_1
18 ; CHECK-NEXT: # %bb.2: # %for.cond.cleanup
19 ; CHECK-NEXT: li a0, 0
24 for.cond.cleanup: ; preds = %for.body
27 for.body: ; preds = %for.body, %entry
28 %indvars.iv1 = phi i64 [ 0, %entry ], [ 1, %for.body ]
29 store i16 1, ptr null, align 4
30 %exitcond.not.31 = icmp eq i64 %indvars.iv1, 0
31 br i1 %exitcond.not.31, label %for.cond.cleanup, label %for.body
34 define void @test_pipelined_1(ptr noalias %in, ptr noalias %out, i32 signext %cnt) {
35 ; CHECK-NOT-PIPELINED-LABEL: test_pipelined_1:
36 ; CHECK-NOT-PIPELINED: # %bb.0: # %entry
37 ; CHECK-NOT-PIPELINED-NEXT: blez a2, .LBB1_3
38 ; CHECK-NOT-PIPELINED-NEXT: # %bb.1: # %for.body.preheader
39 ; CHECK-NOT-PIPELINED-NEXT: addi a2, a2, -1
40 ; CHECK-NOT-PIPELINED-NEXT: sh2add.uw a2, a2, a1
41 ; CHECK-NOT-PIPELINED-NEXT: addi a2, a2, 4
42 ; CHECK-NOT-PIPELINED-NEXT: .LBB1_2: # %for.body
43 ; CHECK-NOT-PIPELINED-NEXT: # =>This Inner Loop Header: Depth=1
44 ; CHECK-NOT-PIPELINED-NEXT: lw a3, 0(a1)
45 ; CHECK-NOT-PIPELINED-NEXT: addi a1, a1, 4
46 ; CHECK-NOT-PIPELINED-NEXT: addi a3, a3, 1
47 ; CHECK-NOT-PIPELINED-NEXT: sw a3, 0(a0)
48 ; CHECK-NOT-PIPELINED-NEXT: addi a0, a0, 4
49 ; CHECK-NOT-PIPELINED-NEXT: bne a1, a2, .LBB1_2
50 ; CHECK-NOT-PIPELINED-NEXT: .LBB1_3: # %for.end
51 ; CHECK-NOT-PIPELINED-NEXT: ret
53 ; CHECK-PIPELINED-LABEL: test_pipelined_1:
54 ; CHECK-PIPELINED: # %bb.0: # %entry
55 ; CHECK-PIPELINED-NEXT: blez a2, .LBB1_6
56 ; CHECK-PIPELINED-NEXT: # %bb.1: # %for.body.preheader
57 ; CHECK-PIPELINED-NEXT: lw a4, 0(a1)
58 ; CHECK-PIPELINED-NEXT: addi a2, a2, -1
59 ; CHECK-PIPELINED-NEXT: sh2add.uw a6, a2, a1
60 ; CHECK-PIPELINED-NEXT: addi a2, a0, 4
61 ; CHECK-PIPELINED-NEXT: addi a1, a1, 4
62 ; CHECK-PIPELINED-NEXT: addi a6, a6, 4
63 ; CHECK-PIPELINED-NEXT: beq a1, a6, .LBB1_5
64 ; CHECK-PIPELINED-NEXT: # %bb.2: # %for.body
65 ; CHECK-PIPELINED-NEXT: lw a5, 0(a1)
66 ; CHECK-PIPELINED-NEXT: addi a3, a2, 4
67 ; CHECK-PIPELINED-NEXT: addi a4, a4, 1
68 ; CHECK-PIPELINED-NEXT: addi a1, a1, 4
69 ; CHECK-PIPELINED-NEXT: beq a1, a6, .LBB1_4
70 ; CHECK-PIPELINED-NEXT: .LBB1_3: # %for.body
71 ; CHECK-PIPELINED-NEXT: # =>This Inner Loop Header: Depth=1
72 ; CHECK-PIPELINED-NEXT: sw a4, 0(a0)
73 ; CHECK-PIPELINED-NEXT: mv a4, a5
74 ; CHECK-PIPELINED-NEXT: lw a5, 0(a1)
75 ; CHECK-PIPELINED-NEXT: mv a0, a2
76 ; CHECK-PIPELINED-NEXT: mv a2, a3
77 ; CHECK-PIPELINED-NEXT: addi a3, a3, 4
78 ; CHECK-PIPELINED-NEXT: addi a4, a4, 1
79 ; CHECK-PIPELINED-NEXT: addi a1, a1, 4
80 ; CHECK-PIPELINED-NEXT: bne a1, a6, .LBB1_3
81 ; CHECK-PIPELINED-NEXT: .LBB1_4:
82 ; CHECK-PIPELINED-NEXT: sw a4, 0(a0)
83 ; CHECK-PIPELINED-NEXT: mv a0, a2
84 ; CHECK-PIPELINED-NEXT: mv a4, a5
85 ; CHECK-PIPELINED-NEXT: .LBB1_5:
86 ; CHECK-PIPELINED-NEXT: addi a4, a4, 1
87 ; CHECK-PIPELINED-NEXT: sw a4, 0(a0)
88 ; CHECK-PIPELINED-NEXT: .LBB1_6: # %for.end
89 ; CHECK-PIPELINED-NEXT: ret
91 %cmp = icmp sgt i32 %cnt, 0
92 br i1 %cmp, label %for.body, label %for.end
94 for.body: ; preds = %entry, %for.body
95 %inc.next = phi i32 [ %inc, %for.body ], [ 0, %entry ]
96 %in.addr.next = phi ptr [ %incdec.in, %for.body ], [ %in, %entry ]
97 %out.addr.next = phi ptr [ %incdec.out, %for.body ], [ %out, %entry ]
98 %0 = load i32, ptr %out.addr.next, align 4
100 store i32 %1, ptr %in.addr.next, align 4
101 %incdec.in = getelementptr inbounds i8, ptr %in.addr.next, i64 4
102 %incdec.out = getelementptr inbounds i8, ptr %out.addr.next, i64 4
103 %inc = add nuw nsw i32 %inc.next, 1
104 %exitcond.not = icmp eq i32 %inc, %cnt
105 br i1 %exitcond.not, label %for.end, label %for.body
107 for.end: ; preds = %for.body, %entry