[TTI] getTypeBasedIntrinsicInstrCost - add basic handling for strided load/store...
[llvm-project.git] / llvm / test / CodeGen / X86 / fake-use-remove-loads.mir
blob3f67f03c9a63d0169df7cbed1c562c6e4b5e3b2e
1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2 # Ensure that loads into FAKE_USEs are correctly removed by the
3 # remove-loads-into-fake-uses pass, and that if the function does not use
4 # instruction referencing then no changes are made.
5 # RUN: llc %s -run-pass remove-loads-into-fake-uses -mtriple=x86_64-unknown-linux -debug-only=remove-loads-into-fake-uses 2>&1 -o - | FileCheck %s
6 # REQUIRES: asserts
8 ## We verify that:
9 ##   - The load into the FAKE_USE is removed, along with the FAKE_USE itself,
10 ##     even when the FAKE_USE is for a subregister of the move.
11 ##   - We correctly handle situations where FAKE_USE has additional `killed`
12 ##     operands added by other passes.
13 ##   - The store to the stack slot still exists.
14 ##   - When the register has a use between the restore and the FAKE_USE, we do
15 ##     not delete the load or fake use.
18 ---
19 name:            enabled
20 alignment:       16
21 tracksRegLiveness: true
22 noPhis:          true
23 noVRegs:         true
24 hasFakeUses:     true
25 tracksDebugUserValues: true
26 debugInstrRef: true
27 liveins:
28   - { reg: '$rdi', virtual-reg: '' }
29   - { reg: '$esi', virtual-reg: '' }
30   - { reg: '$rdx', virtual-reg: '' }
31 frameInfo:
32   isCalleeSavedInfoValid: true
33 stack:
34   - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
35       stack-id: default, callee-saved-register: '', callee-saved-restored: true,
36       debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
37   - { id: 1, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,
38       stack-id: default, callee-saved-register: '', callee-saved-restored: true,
39       debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
40 body:             |
41   bb.0:
42     liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx
44     ; CHECK-LABEL: name: enabled
45     ; CHECK: liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx
46     ; CHECK-NEXT: {{  $}}
47     ; CHECK-NEXT: $rbx = MOV64rr $rdx
48     ; CHECK-NEXT: $r14d = MOV32rr $esi
49     ; CHECK-NEXT: $r15 = MOV64rr $rdi
50     ; CHECK-NEXT: renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12
51     ; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax
53     ;; The store to the stack slot is still present.
54     ; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)
56     ; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)
57     ; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
58     ; CHECK-NEXT: $r13d = MOV32rr killed $eax
59     ; CHECK-NEXT: $rdi = MOV64rr $r15
60     ; CHECK-NEXT: CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
61     ; CHECK-NEXT: dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg
62     ; CHECK-NEXT: renamable $eax = MOV32ri 1
63     ; CHECK-NEXT: TEST8ri renamable $r14b, 1, implicit-def $eflags
64     
65     ;; First FAKE_USE and its corresponding load are removed; second FAKE_USE of
66     ;; a restored value that is also used is preserved.
67     ; CHECK-NEXT: renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)
68     ; CHECK-NEXT: renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags
69     ; CHECK-NEXT: FAKE_USE killed renamable $r11d
71     ; CHECK-NEXT: TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags
72     ; CHECK-NEXT: RET64
74     $rbx = MOV64rr $rdx
75     $r14d = MOV32rr $esi
76     $r15 = MOV64rr $rdi
77     renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12
78     renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax
79     MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)
80     MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)
81     renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
82     $r13d = MOV32rr killed $eax
83     $rdi = MOV64rr $r15
84     CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
85     dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg
86     renamable $eax = MOV32ri 1
87     TEST8ri renamable $r14b, 1, implicit-def $eflags
88     renamable $rax = MOV64rm $rbp, 1, $noreg, -48, $noreg :: (load (s64) from %stack.0)
89     FAKE_USE renamable $eax, implicit killed $rax
90     renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)
91     renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags
92     FAKE_USE killed renamable $r11d
93     TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags
94     RET64
96 ...
97 ---
98 name:            disabled
99 alignment:       16
100 tracksRegLiveness: true
101 noPhis:          true
102 noVRegs:         true
103 hasFakeUses:     true
104 tracksDebugUserValues: true
105 debugInstrRef: false
106 liveins:
107   - { reg: '$rdi', virtual-reg: '' }
108   - { reg: '$esi', virtual-reg: '' }
109   - { reg: '$rdx', virtual-reg: '' }
110 frameInfo:
111   isCalleeSavedInfoValid: true
112 stack:
113   - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
114       stack-id: default, callee-saved-register: '', callee-saved-restored: true,
115       debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
116   - { id: 1, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,
117       stack-id: default, callee-saved-register: '', callee-saved-restored: true,
118       debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
119 body:             |
120   bb.0:
121     liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx
123     ; CHECK-LABEL: name: disabled
124     ; CHECK: liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx
125     ; CHECK-NEXT: {{  $}}
126     ; CHECK-NEXT: $rbx = MOV64rr $rdx
127     ; CHECK-NEXT: $r14d = MOV32rr $esi
128     ; CHECK-NEXT: $r15 = MOV64rr $rdi
129     ; CHECK-NEXT: renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12
130     ; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax
131     ; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)
132     ; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)
133     ; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
134     ; CHECK-NEXT: $r13d = MOV32rr killed $eax
135     ; CHECK-NEXT: $rdi = MOV64rr $r15
136     ; CHECK-NEXT: CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
137     ; CHECK-NEXT: dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg
138     ; CHECK-NEXT: renamable $eax = MOV32ri 1
139     ; CHECK-NEXT: TEST8ri renamable $r14b, 1, implicit-def $eflags
141     ;; Verify that when instr-ref is disabled, we do not remove fake uses.
142     ; CHECK-NEXT: renamable $rax = MOV64rm $rbp, 1, $noreg, -48, $noreg :: (load (s64) from %stack.0)
143     ; CHECK-NEXT: FAKE_USE renamable $eax, implicit killed $rax
144     ; CHECK-NEXT: renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)
145     ; CHECK-NEXT: renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags
146     ; CHECK-NEXT: FAKE_USE killed renamable $r11d
147     ; CHECK-NEXT: TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags
148     ; CHECK-NEXT: RET64
149     $rbx = MOV64rr $rdx
150     $r14d = MOV32rr $esi
151     $r15 = MOV64rr $rdi
152     renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12
153     renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax
154     MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)
155     MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)
156     renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
157     $r13d = MOV32rr killed $eax
158     $rdi = MOV64rr $r15
159     CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
160     dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg
161     renamable $eax = MOV32ri 1
162     TEST8ri renamable $r14b, 1, implicit-def $eflags
163     renamable $rax = MOV64rm $rbp, 1, $noreg, -48, $noreg :: (load (s64) from %stack.0)
164     FAKE_USE renamable $eax, implicit killed $rax
165     renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)
166     renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags
167     FAKE_USE killed renamable $r11d
168     TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags
169     RET64