1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ;RUN: llc < %s -mtriple=riscv64-unknown-linux-gnu -mattr=+m | FileCheck %s
4 ; This test used to cause an infinite loop.
6 @global = global i8 0, align 1
7 @global.1 = global i32 0, align 4
8 @global.2 = global i8 0, align 1
9 @global.3 = global i32 0, align 4
11 define signext i32 @wobble() nounwind {
12 ; CHECK-LABEL: wobble:
13 ; CHECK: # %bb.0: # %bb
14 ; CHECK-NEXT: lui a0, %hi(global)
15 ; CHECK-NEXT: lbu a0, %lo(global)(a0)
16 ; CHECK-NEXT: lui a1, %hi(global.2)
17 ; CHECK-NEXT: lbu a1, %lo(global.2)(a1)
18 ; CHECK-NEXT: addi a0, a0, 1
19 ; CHECK-NEXT: lui a2, %hi(global.1)
20 ; CHECK-NEXT: sw a0, %lo(global.1)(a2)
21 ; CHECK-NEXT: mul a0, a0, a1
22 ; CHECK-NEXT: slli a1, a0, 48
23 ; CHECK-NEXT: lui a2, 52429
24 ; CHECK-NEXT: slli a2, a2, 4
25 ; CHECK-NEXT: mulhu a1, a1, a2
26 ; CHECK-NEXT: srli a1, a1, 18
27 ; CHECK-NEXT: lui a2, %hi(global.3)
28 ; CHECK-NEXT: li a3, 5
29 ; CHECK-NEXT: sw a1, %lo(global.3)(a2)
30 ; CHECK-NEXT: bltu a0, a3, .LBB0_2
31 ; CHECK-NEXT: # %bb.1: # %bb10
32 ; CHECK-NEXT: addi sp, sp, -16
33 ; CHECK-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
34 ; CHECK-NEXT: call quux
35 ; CHECK-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
36 ; CHECK-NEXT: addi sp, sp, 16
37 ; CHECK-NEXT: .LBB0_2: # %bb12
38 ; CHECK-NEXT: li a0, 0
41 %tmp = load i8, ptr @global, align 1
42 %tmp1 = zext i8 %tmp to i32
43 %tmp2 = add nuw nsw i32 %tmp1, 1
44 store i32 %tmp2, ptr @global.1, align 4
45 %tmp3 = load i8, ptr @global.2, align 1
46 %tmp4 = zext i8 %tmp3 to i32
47 %tmp5 = mul nuw nsw i32 %tmp2, %tmp4
48 %tmp6 = trunc i32 %tmp5 to i16
49 %tmp7 = udiv i16 %tmp6, 5
50 %tmp8 = zext i16 %tmp7 to i32
51 store i32 %tmp8, ptr @global.3, align 4
52 %tmp9 = icmp ult i32 %tmp5, 5
53 br i1 %tmp9, label %bb12, label %bb10
56 %tmp11 = tail call signext i32 @quux()
59 bb12: ; preds = %bb10, %bb
63 declare signext i32 @quux(...)