Matthias Braun | f0b68d3 | 2017-03-17 00:41:39 +0000 | [diff] [blame] | 1 | # RUN: llc -o - %s -mtriple=amdgcn-- -mcpu=fiji -verify-machineinstrs -run-pass=greedy,virtregrewriter | FileCheck %s |
| 2 | --- | |
Matt Arsenault | 3dbeefa | 2017-03-21 21:39:51 +0000 | [diff] [blame] | 3 | define amdgpu_kernel void @func0() #0 { ret void } |
| 4 | define amdgpu_kernel void @func1() #0 { ret void } |
Matthias Braun | 8445cbd | 2017-03-21 21:58:08 +0000 | [diff] [blame] | 5 | define amdgpu_kernel void @splitHoist() #0 { ret void } |
Matthias Braun | f0b68d3 | 2017-03-17 00:41:39 +0000 | [diff] [blame] | 6 | |
| 7 | attributes #0 = { "amdgpu-num-sgpr"="12" } |
| 8 | ... |
| 9 | --- |
| 10 | # Make sure we only get a single spill+reload even if liverange splitting |
| 11 | # created a sequence of multiple copy instructions. |
| 12 | # CHECK-LABEL: name: func0 |
| 13 | # CHECK: SI_SPILL_S128_SAVE |
| 14 | # CHECK-NOT: SI_SPILL_S128_SAVE |
| 15 | # CHECK: S_NOP 0 |
| 16 | # CHECK: SI_SPILL_S128_RESTORE |
| 17 | # CHECK-NOT: SI_SPILL_S128_RESTORE |
| 18 | name: func0 |
| 19 | body: | |
| 20 | bb.0: |
| 21 | S_NOP 0, implicit-def undef %0.sub0 : sreg_128 |
| 22 | S_NOP 0, implicit-def %0.sub3 : sreg_128 |
| 23 | |
| 24 | ; Clobber registers |
Puyan Lotfi | 43e94b1 | 2018-01-31 22:04:26 +0000 | [diff] [blame] | 25 | S_NOP 0, implicit-def dead $sgpr0, implicit-def dead $sgpr1, implicit-def dead $sgpr2, implicit-def dead $sgpr3, implicit-def dead $sgpr4, implicit-def dead $sgpr5, implicit-def dead $sgpr6, implicit-def dead $sgpr7, implicit-def dead $sgpr8, implicit-def dead $sgpr9, implicit-def dead $sgpr10, implicit-def dead $sgpr11 |
Matthias Braun | f0b68d3 | 2017-03-17 00:41:39 +0000 | [diff] [blame] | 26 | |
| 27 | S_NOP 0, implicit %0.sub0 |
| 28 | S_NOP 0, implicit %0.sub3 |
| 29 | S_NOP 0, implicit %0.sub0 |
| 30 | S_NOP 0, implicit %0.sub3 |
| 31 | ... |
| 32 | --- |
| 33 | # LiveRange splitting should split this into 2 intervals with the second getting |
| 34 | # allocated to sgpr0_sgpr1 and the first to something else so we see two copies |
| 35 | # in between for the two subregisters that are alive. |
| 36 | # CHECK-LABEL: name: func1 |
Puyan Lotfi | 43e94b1 | 2018-01-31 22:04:26 +0000 | [diff] [blame] | 37 | # CHECK: [[REG0:\$sgpr[0-9]+]] = COPY $sgpr0 |
| 38 | # CHECK: [[REG1:\$sgpr[0-9]+]] = COPY $sgpr2 |
Matthias Braun | f0b68d3 | 2017-03-17 00:41:39 +0000 | [diff] [blame] | 39 | # CHECK: S_NOP 0 |
Geoff Berry | 60c4310 | 2017-12-12 17:53:59 +0000 | [diff] [blame] | 40 | # CHECK: S_NOP 0, implicit renamable [[REG0]] |
| 41 | # CHECK: S_NOP 0, implicit renamable [[REG1]] |
Puyan Lotfi | 43e94b1 | 2018-01-31 22:04:26 +0000 | [diff] [blame] | 42 | # CHECK: $sgpr0 = COPY renamable [[REG0]] |
| 43 | # CHECK: $sgpr2 = COPY renamable [[REG1]] |
Matthias Braun | f0b68d3 | 2017-03-17 00:41:39 +0000 | [diff] [blame] | 44 | # CHECK: S_NOP |
Puyan Lotfi | 43e94b1 | 2018-01-31 22:04:26 +0000 | [diff] [blame] | 45 | # CHECK: S_NOP 0, implicit renamable $sgpr0 |
| 46 | # CHECK: S_NOP 0, implicit renamable $sgpr2 |
Matthias Braun | f0b68d3 | 2017-03-17 00:41:39 +0000 | [diff] [blame] | 47 | name: func1 |
| 48 | tracksRegLiveness: true |
| 49 | body: | |
| 50 | bb.0: |
Puyan Lotfi | 43e94b1 | 2018-01-31 22:04:26 +0000 | [diff] [blame] | 51 | liveins: $sgpr0, $sgpr1, $sgpr2 |
| 52 | undef %0.sub0 : sreg_128 = COPY $sgpr0 |
| 53 | %0.sub2 = COPY $sgpr2 |
Matthias Braun | f0b68d3 | 2017-03-17 00:41:39 +0000 | [diff] [blame] | 54 | |
Puyan Lotfi | 43e94b1 | 2018-01-31 22:04:26 +0000 | [diff] [blame] | 55 | S_NOP 0, implicit-def dead $sgpr0, implicit-def dead $sgpr1 |
Matthias Braun | f0b68d3 | 2017-03-17 00:41:39 +0000 | [diff] [blame] | 56 | |
| 57 | S_NOP 0, implicit %0.sub0 |
| 58 | S_NOP 0, implicit %0.sub2 |
| 59 | |
| 60 | ; Clobber everything but sgpr0-sgpr3 |
Puyan Lotfi | 43e94b1 | 2018-01-31 22:04:26 +0000 | [diff] [blame] | 61 | S_NOP 0, implicit-def dead $sgpr4, implicit-def dead $sgpr5, implicit-def dead $sgpr6, implicit-def dead $sgpr7, implicit-def dead $sgpr8, implicit-def dead $sgpr9, implicit-def dead $sgpr10, implicit-def dead $sgpr11, implicit-def dead $sgpr12, implicit-def dead $sgpr13, implicit-def dead $sgpr14, implicit-def dead $sgpr15, implicit-def dead $vcc_lo, implicit-def dead $vcc_hi |
Matthias Braun | f0b68d3 | 2017-03-17 00:41:39 +0000 | [diff] [blame] | 62 | |
| 63 | S_NOP 0, implicit %0.sub0 |
| 64 | S_NOP 0, implicit %0.sub2 |
| 65 | ... |
Matthias Braun | 8445cbd | 2017-03-21 21:58:08 +0000 | [diff] [blame] | 66 | --- |
| 67 | # Check that copy hoisting out of loops works. This mainly should not crash the |
| 68 | # compiler when it hoists a subreg copy sequence. |
| 69 | # CHECK-LABEL: name: splitHoist |
Puyan Lotfi | 43e94b1 | 2018-01-31 22:04:26 +0000 | [diff] [blame] | 70 | # CHECK: S_NOP 0, implicit-def renamable $sgpr0 |
| 71 | # CHECK: S_NOP 0, implicit-def renamable $sgpr3 |
Matthias Braun | 8445cbd | 2017-03-21 21:58:08 +0000 | [diff] [blame] | 72 | # CHECK-NEXT: SI_SPILL_S128_SAVE |
| 73 | name: splitHoist |
| 74 | tracksRegLiveness: true |
| 75 | body: | |
| 76 | bb.0: |
| 77 | successors: %bb.1, %bb.2 |
| 78 | S_NOP 0, implicit-def undef %0.sub0 : sreg_128 |
| 79 | S_NOP 0, implicit-def %0.sub3 : sreg_128 |
| 80 | |
Puyan Lotfi | 43e94b1 | 2018-01-31 22:04:26 +0000 | [diff] [blame] | 81 | S_CBRANCH_VCCNZ %bb.1, implicit undef $vcc |
Matthias Braun | 8445cbd | 2017-03-21 21:58:08 +0000 | [diff] [blame] | 82 | S_BRANCH %bb.2 |
| 83 | |
| 84 | bb.1: |
| 85 | successors: %bb.1, %bb.3 |
| 86 | S_NOP 0, implicit %0.sub0 |
| 87 | |
| 88 | ; Clobber registers |
Puyan Lotfi | 43e94b1 | 2018-01-31 22:04:26 +0000 | [diff] [blame] | 89 | S_NOP 0, implicit-def dead $sgpr0, implicit-def dead $sgpr1, implicit-def dead $sgpr2, implicit-def dead $sgpr3, implicit-def dead $sgpr4, implicit-def dead $sgpr5, implicit-def dead $sgpr6, implicit-def dead $sgpr7, implicit-def dead $sgpr8, implicit-def dead $sgpr9, implicit-def dead $sgpr10, implicit-def dead $sgpr11 |
Matthias Braun | 8445cbd | 2017-03-21 21:58:08 +0000 | [diff] [blame] | 90 | |
Puyan Lotfi | 43e94b1 | 2018-01-31 22:04:26 +0000 | [diff] [blame] | 91 | S_CBRANCH_VCCNZ %bb.1, implicit undef $vcc |
Matthias Braun | 8445cbd | 2017-03-21 21:58:08 +0000 | [diff] [blame] | 92 | S_BRANCH %bb.3 |
| 93 | |
| 94 | bb.2: |
| 95 | successors: %bb.3 |
| 96 | ; Clobber registers |
Puyan Lotfi | 43e94b1 | 2018-01-31 22:04:26 +0000 | [diff] [blame] | 97 | S_NOP 0, implicit-def dead $sgpr0, implicit-def dead $sgpr1, implicit-def dead $sgpr2, implicit-def dead $sgpr3, implicit-def dead $sgpr4, implicit-def dead $sgpr5, implicit-def dead $sgpr6, implicit-def dead $sgpr7, implicit-def dead $sgpr8, implicit-def dead $sgpr9, implicit-def dead $sgpr10, implicit-def dead $sgpr11 |
Matthias Braun | 8445cbd | 2017-03-21 21:58:08 +0000 | [diff] [blame] | 98 | S_BRANCH %bb.3 |
| 99 | |
| 100 | bb.3: |
| 101 | S_NOP 0, implicit %0.sub0 |
| 102 | S_NOP 0, implicit %0.sub3 |
| 103 | S_NOP 0, implicit %0.sub0 |
| 104 | S_NOP 0, implicit %0.sub3 |
| 105 | ... |