1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s | FileCheck %s
3 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s | FileCheck %s
5 @x = global [6 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5], align 4
6 @check = global [6 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5], align 4
8 ; This test case checks whether the base address of an array is repeatedly
9 ; rematerialised within a unrolled loop.
10 define signext i32 @unroll_loop_cse() {
11 ; CHECK-LABEL: unroll_loop_cse:
13 ; CHECK-NEXT: lui a0, %hi(x)
14 ; CHECK-NEXT: lw a1, %lo(x)(a0)
15 ; CHECK-NEXT: lui a0, %hi(check)
16 ; CHECK-NEXT: lw a2, %lo(check)(a0)
17 ; CHECK-NEXT: li a0, 1
18 ; CHECK-NEXT: bne a1, a2, .LBB0_6
19 ; CHECK-NEXT: # %bb.1:
20 ; CHECK-NEXT: lui a1, %hi(x)
21 ; CHECK-NEXT: addi a1, a1, %lo(x)
22 ; CHECK-NEXT: lw a3, 4(a1)
23 ; CHECK-NEXT: lui a2, %hi(check)
24 ; CHECK-NEXT: addi a2, a2, %lo(check)
25 ; CHECK-NEXT: lw a4, 4(a2)
26 ; CHECK-NEXT: bne a3, a4, .LBB0_6
27 ; CHECK-NEXT: # %bb.2:
28 ; CHECK-NEXT: lw a3, 8(a1)
29 ; CHECK-NEXT: lw a4, 8(a2)
30 ; CHECK-NEXT: bne a3, a4, .LBB0_6
31 ; CHECK-NEXT: # %bb.3:
32 ; CHECK-NEXT: lw a3, 12(a1)
33 ; CHECK-NEXT: lw a4, 12(a2)
34 ; CHECK-NEXT: bne a3, a4, .LBB0_6
35 ; CHECK-NEXT: # %bb.4:
36 ; CHECK-NEXT: lw a3, 16(a1)
37 ; CHECK-NEXT: lw a4, 16(a2)
38 ; CHECK-NEXT: bne a3, a4, .LBB0_6
39 ; CHECK-NEXT: # %bb.5:
40 ; CHECK-NEXT: lw a0, 20(a1)
41 ; CHECK-NEXT: lw a1, 20(a2)
42 ; CHECK-NEXT: xor a0, a0, a1
43 ; CHECK-NEXT: snez a0, a0
44 ; CHECK-NEXT: .LBB0_6:
46 %1 = load i32, ptr @x, align 4
47 %2 = load i32, ptr @check, align 4
48 %3 = icmp eq i32 %1, %2
49 br i1 %3, label %4, label %25
52 %5 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @x, i64 0, i64 1), align 4
53 %6 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @check, i64 0, i64 1), align 4
54 %7 = icmp eq i32 %5, %6
55 br i1 %7, label %8, label %25
58 %9 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @x, i64 0, i64 2), align 4
59 %10 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @check, i64 0, i64 2), align 4
60 %11 = icmp eq i32 %9, %10
61 br i1 %11, label %12, label %25
64 %13 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @x, i64 0, i64 3), align 4
65 %14 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @check, i64 0, i64 3), align 4
66 %15 = icmp eq i32 %13, %14
67 br i1 %15, label %16, label %25
70 %17 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @x, i64 0, i64 4), align 4
71 %18 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @check, i64 0, i64 4), align 4
72 %19 = icmp eq i32 %17, %18
73 br i1 %19, label %20, label %25
76 %21 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @x, i64 0, i64 5), align 4
77 %22 = load i32, ptr getelementptr inbounds ([6 x i32], ptr @check, i64 0, i64 5), align 4
78 %23 = icmp ne i32 %21, %22
79 %24 = zext i1 %23 to i32
83 %26 = phi i32 [ 1, %0 ], [ 1, %4 ], [ 1, %8 ], [ 1, %12 ], [ 1, %16 ], [ %24, %20 ]