OSDN Git Service

Update LLVM for 3.5 rebase (r209712).
[android-x86/external-llvm.git] / test / CodeGen / Mips / longbranch.ll
1 ; RUN: llc -march=mipsel < %s | FileCheck %s
2 ; RUN: llc -march=mipsel -force-mips-long-branch -O3 < %s \
3 ; RUN:   | FileCheck %s -check-prefix=O32
4 ; RUN: llc -march=mips64el -mcpu=mips4 -mattr=n64 -force-mips-long-branch -O3 \
5 ; RUN:   < %s | FileCheck %s -check-prefix=N64
6 ; RUN: llc -march=mips64el -mcpu=mips64 -mattr=n64 -force-mips-long-branch -O3 \
7 ; RUN:   < %s | FileCheck %s -check-prefix=N64
8 ; RUN: llc -march=mipsel -mcpu=mips32r2 -mattr=micromips \
9 ; RUN:   -force-mips-long-branch -O3 < %s | FileCheck %s -check-prefix=MICROMIPS
10
11
12 @x = external global i32
13
14 define void @test1(i32 %s) {
15 entry:
16   %cmp = icmp eq i32 %s, 0
17   br i1 %cmp, label %end, label %then
18
19 then:
20   store i32 1, i32* @x, align 4
21   br label %end
22
23 end:
24   ret void
25
26
27 ; First check the normal version (without long branch).  beqz jumps to return,
28 ; and fallthrough block stores 1 to global variable.
29
30 ; CHECK:        lui     $[[R0:[0-9]+]], %hi(_gp_disp)
31 ; CHECK:        addiu   $[[R0]], $[[R0]], %lo(_gp_disp)
32 ; CHECK:        beqz    $4, $[[BB0:BB[0-9_]+]]
33 ; CHECK:        addu    $[[GP:[0-9]+]], $[[R0]], $25
34 ; CHECK:        lw      $[[R1:[0-9]+]], %got(x)($[[GP]])
35 ; CHECK:        addiu   $[[R2:[0-9]+]], $zero, 1
36 ; CHECK:        sw      $[[R2]], 0($[[R1]])
37 ; CHECK:   $[[BB0]]:
38 ; CHECK:        jr      $ra
39 ; CHECK:        nop
40
41
42 ; Check the MIPS32 version.  Check that branch logic is inverted, so that the
43 ; target of the new branch (bnez) is the fallthrough block of the original
44 ; branch.  Check that fallthrough block of the new branch contains long branch
45 ; expansion which at the end indirectly jumps to the target of the original
46 ; branch.
47
48 ; O32:        lui     $[[R0:[0-9]+]], %hi(_gp_disp)
49 ; O32:        addiu   $[[R0]], $[[R0]], %lo(_gp_disp)
50 ; O32:        bnez    $4, $[[BB0:BB[0-9_]+]]
51 ; O32:        addu    $[[GP:[0-9]+]], $[[R0]], $25
52
53 ; Check for long branch expansion:
54 ; O32:             addiu   $sp, $sp, -8
55 ; O32-NEXT:        sw      $ra, 0($sp)
56 ; O32-NEXT:        lui     $1, %hi(($[[BB2:BB[0-9_]+]])-($[[BB1:BB[0-9_]+]]))
57 ; O32-NEXT:        bal     $[[BB1]]
58 ; O32-NEXT:        addiu   $1, $1, %lo(($[[BB2]])-($[[BB1]]))
59 ; O32-NEXT:   $[[BB1]]:
60 ; O32-NEXT:        addu    $1, $ra, $1
61 ; O32-NEXT:        lw      $ra, 0($sp)
62 ; O32-NEXT:        jr      $1
63 ; O32-NEXT:        addiu   $sp, $sp, 8
64
65 ; O32:   $[[BB0]]:
66 ; O32:        lw      $[[R1:[0-9]+]], %got(x)($[[GP]])
67 ; O32:        addiu   $[[R2:[0-9]+]], $zero, 1
68 ; O32:        sw      $[[R2]], 0($[[R1]])
69 ; O32:   $[[BB2]]:
70 ; O32:        jr      $ra
71 ; O32:        nop
72
73
74 ; Check the MIPS64 version.
75
76 ; N64:        lui     $[[R0:[0-9]+]], %hi(%neg(%gp_rel(test1)))
77 ; N64:        bnez    $4, $[[BB0:BB[0-9_]+]]
78 ; N64:        daddu   $[[R1:[0-9]+]], $[[R0]], $25
79
80 ; Check for long branch expansion:
81 ; N64:           daddiu  $sp, $sp, -16
82 ; N64-NEXT:      sd      $ra, 0($sp)
83 ; N64-NEXT:      daddiu  $1, $zero, %hi(($[[BB2:BB[0-9_]+]])-($[[BB1:BB[0-9_]+]]))
84 ; N64-NEXT:      dsll    $1, $1, 16
85 ; N64-NEXT:      bal     $[[BB1]]
86 ; N64-NEXT:      daddiu  $1, $1, %lo(($[[BB2]])-($[[BB1]]))
87 ; N64-NEXT:  $[[BB1]]:
88 ; N64-NEXT:      daddu   $1, $ra, $1
89 ; N64-NEXT:      ld      $ra, 0($sp)
90 ; N64-NEXT:      jr      $1
91 ; N64-NEXT:      daddiu  $sp, $sp, 16
92
93 ; N64:   $[[BB0]]:
94 ; N64:        daddiu  $[[GP:[0-9]+]], $[[R1]], %lo(%neg(%gp_rel(test1)))
95 ; N64:        ld      $[[R2:[0-9]+]], %got_disp(x)($[[GP]])
96 ; N64:        addiu   $[[R3:[0-9]+]], $zero, 1
97 ; N64:        sw      $[[R3]], 0($[[R2]])
98 ; N64:   $[[BB2]]:
99 ; N64:        jr      $ra
100 ; N64:        nop
101
102
103 ; Check the microMIPS version.
104
105 ; MICROMIPS:        lui     $[[R0:[0-9]+]], %hi(_gp_disp)
106 ; MICROMIPS:        addiu   $[[R0]], $[[R0]], %lo(_gp_disp)
107 ; MICROMIPS:        bnez    $4, $[[BB0:BB[0-9_]+]]
108 ; MICROMIPS:        addu    $[[GP:[0-9]+]], $[[R0]], $25
109
110 ; Check for long branch expansion:
111 ; MICROMIPS:          addiu   $sp, $sp, -8
112 ; MICROMIPS-NEXT:     sw      $ra, 0($sp)
113 ; MICROMIPS-NEXT:     lui     $1, %hi(($[[BB2:BB[0-9_]+]])-($[[BB1:BB[0-9_]+]]))
114 ; MICROMIPS-NEXT:     bal     $[[BB1]]
115 ; MICROMIPS-NEXT:     addiu   $1, $1, %lo(($[[BB2]])-($[[BB1]]))
116 ; MICROMIPS-NEXT:  $[[BB1]]:
117 ; MICROMIPS-NEXT:     addu    $1, $ra, $1
118 ; MICROMIPS-NEXT:     lw      $ra, 0($sp)
119 ; MICROMIPS-NEXT:     jr      $1
120 ; MICROMIPS-NEXT:     addiu   $sp, $sp, 8
121
122 ; MICROMIPS:   $[[BB0]]:
123 ; MICROMIPS:        lw      $[[R1:[0-9]+]], %got(x)($[[GP]])
124 ; MICROMIPS:        addiu   $[[R2:[0-9]+]], $zero, 1
125 ; MICROMIPS:        sw      $[[R2]], 0($[[R1]])
126 ; MICROMIPS:   $[[BB2]]:
127 ; MICROMIPS:        jr      $ra
128 ; MICROMIPS:        nop
129 }