long-branch.ll
4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; Except for the NACL version which isn't parsed by update_llc_test_checks.py
; RUN: llc -mtriple=mipsel-unknown-linux-gnu -force-mips-long-branch -O3 \
; RUN: -mcpu=mips32r2 -mattr=+use-indirect-jump-hazard -relocation-model=pic \
; RUN: -verify-machineinstrs < %s | FileCheck %s -check-prefix=O32-PIC
; RUN: llc -mtriple=mipsel-unknown-linux-gnu -mcpu=mips32r6 \
; RUN: -force-mips-long-branch -O3 -mattr=+use-indirect-jump-hazard \
; RUN: -relocation-model=pic -verify-machineinstrs < %s \
; RUN: | FileCheck %s -check-prefix=O32-R6-PIC
; RUN: llc -mtriple=mips64el-unknown-linux-gnu -mcpu=mips64r2 -target-abi=n64 \
; RUN: -force-mips-long-branch -O3 -relocation-model=pic \
; RUN: -mattr=+use-indirect-jump-hazard -verify-machineinstrs \
; RUN: < %s | FileCheck %s -check-prefix=MIPS64
; RUN: llc -mtriple=mips64el-unknown-linux-gnu -mcpu=mips64r6 -target-abi=n64 \
; RUN: -force-mips-long-branch -O3 -mattr=+use-indirect-jump-hazard \
; RUN: -relocation-model=pic -verify-machineinstrs < %s \
; RUN: | FileCheck %s -check-prefix=N64-R6
; Test that the long branches also get changed to their hazard variants.
@x = external global i32
define void @test1(i32 signext %s) {
; O32-PIC-LABEL: test1:
; O32-PIC: # %bb.0: # %entry
; O32-PIC-NEXT: lui $2, %hi(_gp_disp)
; O32-PIC-NEXT: addiu $2, $2, %lo(_gp_disp)
; O32-PIC-NEXT: bnez $4, $BB0_3
; O32-PIC-NEXT: addu $2, $2, $25
; O32-PIC-NEXT: # %bb.1: # %entry
; O32-PIC-NEXT: addiu $sp, $sp, -8
; O32-PIC-NEXT: sw $ra, 0($sp)
; O32-PIC-NEXT: lui $1, %hi(($BB0_4)-($BB0_2))
; O32-PIC-NEXT: bal $BB0_2
; O32-PIC-NEXT: addiu $1, $1, %lo(($BB0_4)-($BB0_2))
; O32-PIC-NEXT: $BB0_2: # %entry
; O32-PIC-NEXT: addu $1, $ra, $1
; O32-PIC-NEXT: lw $ra, 0($sp)
; O32-PIC-NEXT: jr.hb $1
; O32-PIC-NEXT: addiu $sp, $sp, 8
; O32-PIC-NEXT: $BB0_3: # %then
; O32-PIC-NEXT: lw $1, %got(x)($2)
; O32-PIC-NEXT: addiu $2, $zero, 1
; O32-PIC-NEXT: sw $2, 0($1)
; O32-PIC-NEXT: $BB0_4: # %end
; O32-PIC-NEXT: jr $ra
; O32-PIC-NEXT: nop
;
; O32-R6-PIC-LABEL: test1:
; O32-R6-PIC: # %bb.0: # %entry
; O32-R6-PIC-NEXT: lui $2, %hi(_gp_disp)
; O32-R6-PIC-NEXT: addiu $2, $2, %lo(_gp_disp)
; O32-R6-PIC-NEXT: bnez $4, $BB0_3
; O32-R6-PIC-NEXT: addu $2, $2, $25
; O32-R6-PIC-NEXT: # %bb.1: # %entry
; O32-R6-PIC-NEXT: addiu $sp, $sp, -8
; O32-R6-PIC-NEXT: sw $ra, 0($sp)
; O32-R6-PIC-NEXT: lui $1, %hi(($BB0_4)-($BB0_2))
; O32-R6-PIC-NEXT: addiu $1, $1, %lo(($BB0_4)-($BB0_2))
; O32-R6-PIC-NEXT: balc $BB0_2
; O32-R6-PIC-NEXT: $BB0_2: # %entry
; O32-R6-PIC-NEXT: addu $1, $ra, $1
; O32-R6-PIC-NEXT: lw $ra, 0($sp)
; O32-R6-PIC-NEXT: jr.hb $1
; O32-R6-PIC-NEXT: addiu $sp, $sp, 8
; O32-R6-PIC-NEXT: $BB0_3: # %then
; O32-R6-PIC-NEXT: lw $1, %got(x)($2)
; O32-R6-PIC-NEXT: addiu $2, $zero, 1
; O32-R6-PIC-NEXT: sw $2, 0($1)
; O32-R6-PIC-NEXT: $BB0_4: # %end
; O32-R6-PIC-NEXT: jrc $ra
;
; MIPS64-LABEL: test1:
; MIPS64: # %bb.0: # %entry
; MIPS64-NEXT: lui $1, %hi(%neg(%gp_rel(test1)))
; MIPS64-NEXT: bnez $4, .LBB0_3
; MIPS64-NEXT: daddu $2, $1, $25
; MIPS64-NEXT: # %bb.1: # %entry
; MIPS64-NEXT: daddiu $sp, $sp, -16
; MIPS64-NEXT: sd $ra, 0($sp)
; MIPS64-NEXT: daddiu $1, $zero, %hi(.LBB0_4-.LBB0_2)
; MIPS64-NEXT: dsll $1, $1, 16
; MIPS64-NEXT: bal .LBB0_2
; MIPS64-NEXT: daddiu $1, $1, %lo(.LBB0_4-.LBB0_2)
; MIPS64-NEXT: .LBB0_2: # %entry
; MIPS64-NEXT: daddu $1, $ra, $1
; MIPS64-NEXT: ld $ra, 0($sp)
; MIPS64-NEXT: jr.hb $1
; MIPS64-NEXT: daddiu $sp, $sp, 16
; MIPS64-NEXT: .LBB0_3: # %then
; MIPS64-NEXT: daddiu $1, $2, %lo(%neg(%gp_rel(test1)))
; MIPS64-NEXT: addiu $2, $zero, 1
; MIPS64-NEXT: ld $1, %got_disp(x)($1)
; MIPS64-NEXT: sw $2, 0($1)
; MIPS64-NEXT: .LBB0_4: # %end
; MIPS64-NEXT: jr $ra
; MIPS64-NEXT: nop
;
; N64-R6-LABEL: test1:
; N64-R6: # %bb.0: # %entry
; N64-R6-NEXT: lui $1, %hi(%neg(%gp_rel(test1)))
; N64-R6-NEXT: bnez $4, .LBB0_3
; N64-R6-NEXT: daddu $2, $1, $25
; N64-R6-NEXT: # %bb.1: # %entry
; N64-R6-NEXT: daddiu $sp, $sp, -16
; N64-R6-NEXT: sd $ra, 0($sp)
; N64-R6-NEXT: daddiu $1, $zero, %hi(.LBB0_4-.LBB0_2)
; N64-R6-NEXT: dsll $1, $1, 16
; N64-R6-NEXT: daddiu $1, $1, %lo(.LBB0_4-.LBB0_2)
; N64-R6-NEXT: balc .LBB0_2
; N64-R6-NEXT: .LBB0_2: # %entry
; N64-R6-NEXT: daddu $1, $ra, $1
; N64-R6-NEXT: ld $ra, 0($sp)
; N64-R6-NEXT: jr.hb $1
; N64-R6-NEXT: daddiu $sp, $sp, 16
; N64-R6-NEXT: .LBB0_3: # %then
; N64-R6-NEXT: daddiu $1, $2, %lo(%neg(%gp_rel(test1)))
; N64-R6-NEXT: addiu $2, $zero, 1
; N64-R6-NEXT: ld $1, %got_disp(x)($1)
; N64-R6-NEXT: sw $2, 0($1)
; N64-R6-NEXT: .LBB0_4: # %end
; N64-R6-NEXT: jrc $ra
entry:
%cmp = icmp eq i32 %s, 0
br i1 %cmp, label %end, label %then
then:
store i32 1, i32* @x, align 4
br label %end
end:
ret void
}