1; RUN: llc < %s > %t
2; PR6283
3
4; Tricky coalescer bug:
5; After coalescing %RAX with a virtual register, this instruction was rematted:
6;
7;   %EAX = MOV32rr killed %reg1070
8;
9; This instruction silently defined %RAX, and when rematting removed the
10; instruction, the live interval for %RAX was not properly updated. The valno
11; referred to a deleted instruction and bad things happened.
12;
13; The fix is to implicitly define %RAX when coalescing:
14;
15;   %EAX = MOV32rr killed %reg1070, implicit-def %RAX
16;
17
18target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
19target triple = "x86_64-unknown-linux-gnu"
20
21module asm "\09.ident\09\22GCC: (GNU) 4.5.0 20100212 (experimental) LLVM: 95975\22"
22
23%0 = type { %"union gimple_statement_d"* }
24%"BITMAP_WORD[]" = type [2 x i64]
25%"uchar[]" = type [1 x i8]
26%"char[]" = type [4 x i8]
27%"enum dom_state[]" = type [2 x i32]
28%"int[]" = type [4 x i32]
29%"struct VEC_basic_block_base" = type { i32, i32, [1 x %"struct basic_block_def"*] }
30%"struct VEC_basic_block_gc" = type { %"struct VEC_basic_block_base" }
31%"struct VEC_edge_base" = type { i32, i32, [1 x %"struct edge_def"*] }
32%"struct VEC_edge_gc" = type { %"struct VEC_edge_base" }
33%"struct VEC_gimple_base" = type { i32, i32, [1 x %"union gimple_statement_d"*] }
34%"struct VEC_gimple_gc" = type { %"struct VEC_gimple_base" }
35%"struct VEC_iv_cand_p_base" = type { i32, i32, [1 x %"struct iv_cand"*] }
36%"struct VEC_iv_cand_p_heap" = type { %"struct VEC_iv_cand_p_base" }
37%"struct VEC_iv_use_p_base" = type { i32, i32, [1 x %"struct iv_use"*] }
38%"struct VEC_iv_use_p_heap" = type { %"struct VEC_iv_use_p_base" }
39%"struct VEC_loop_p_base" = type { i32, i32, [1 x %"struct loop"*] }
40%"struct VEC_loop_p_gc" = type { %"struct VEC_loop_p_base" }
41%"struct VEC_rtx_base" = type { i32, i32, [1 x %"struct rtx_def"*] }
42%"struct VEC_rtx_gc" = type { %"struct VEC_rtx_base" }
43%"struct VEC_tree_base" = type { i32, i32, [1 x %"union tree_node"*] }
44%"struct VEC_tree_gc" = type { %"struct VEC_tree_base" }
45%"struct _obstack_chunk" = type { i8*, %"struct _obstack_chunk"*, %"char[]" }
46%"struct basic_block_def" = type { %"struct VEC_edge_gc"*, %"struct VEC_edge_gc"*, i8*, %"struct loop"*, [2 x %"struct et_node"*], %"struct basic_block_def"*, %"struct basic_block_def"*, %"union basic_block_il_dependent", i64, i32, i32, i32, i32, i32 }
47%"struct bitmap_element" = type { %"struct bitmap_element"*, %"struct bitmap_element"*, i32, %"BITMAP_WORD[]" }
48%"struct bitmap_head_def" = type { %"struct bitmap_element"*, %"struct bitmap_element"*, i32, %"struct bitmap_obstack"* }
49%"struct bitmap_obstack" = type { %"struct bitmap_element"*, %"struct bitmap_head_def"*, %"struct obstack" }
50%"struct block_symbol" = type { [3 x %"union rtunion"], %"struct object_block"*, i64 }
51%"struct comp_cost" = type { i32, i32 }
52%"struct control_flow_graph" = type { %"struct basic_block_def"*, %"struct basic_block_def"*, %"struct VEC_basic_block_gc"*, i32, i32, i32, %"struct VEC_basic_block_gc"*, i32, %"enum dom_state[]", %"enum dom_state[]", i32, i32 }
53%"struct cost_pair" = type { %"struct iv_cand"*, %"struct comp_cost", %"struct bitmap_head_def"*, %"union tree_node"* }
54%"struct def_optype_d" = type { %"struct def_optype_d"*, %"union tree_node"** }
55%"struct double_int" = type { i64, i64 }
56%"struct edge_def" = type { %"struct basic_block_def"*, %"struct basic_block_def"*, %"union edge_def_insns", i8*, %"union tree_node"*, i32, i32, i32, i32, i64 }
57%"struct eh_status" = type opaque
58%"struct et_node" = type opaque
59%"struct function" = type { %"struct eh_status"*, %"struct control_flow_graph"*, %"struct gimple_seq_d"*, %"struct gimple_df"*, %"struct loops"*, %"struct htab"*, %"union tree_node"*, %"union tree_node"*, %"union tree_node"*, %"union tree_node"*, %"struct machine_function"*, %"struct language_function"*, %"struct htab"*, i32, i32, i32, i32, i32, i32, i8*, i8, i8, i8, i8 }
60%"struct gimple_bb_info" = type { %"struct gimple_seq_d"*, %"struct gimple_seq_d"* }
61%"struct gimple_df" = type { %"struct htab"*, %"struct VEC_gimple_gc"*, %"struct VEC_tree_gc"*, %"union tree_node"*, %"struct pt_solution", %"struct pt_solution", %"struct pointer_map_t"*, %"union tree_node"*, %"struct htab"*, %"struct bitmap_head_def"*, i8, %"struct ssa_operands" }
62%"struct gimple_seq_d" = type { %"struct gimple_seq_node_d"*, %"struct gimple_seq_node_d"*, %"struct gimple_seq_d"* }
63%"struct gimple_seq_node_d" = type { %"union gimple_statement_d"*, %"struct gimple_seq_node_d"*, %"struct gimple_seq_node_d"* }
64%"struct gimple_statement_base" = type { i8, i8, i16, i32, i32, i32, %"struct basic_block_def"*, %"union tree_node"* }
65%"struct phi_arg_d[]" = type [1 x %"struct phi_arg_d"]
66%"struct gimple_statement_phi" = type { %"struct gimple_statement_base", i32, i32, %"union tree_node"*, %"struct phi_arg_d[]" }
67%"struct htab" = type { i32 (i8*)*, i32 (i8*, i8*)*, void (i8*)*, i8**, i64, i64, i64, i32, i32, i8* (i64, i64)*, void (i8*)*, i8*, i8* (i8*, i64, i64)*, void (i8*, i8*)*, i32 }
68%"struct iv" = type { %"union tree_node"*, %"union tree_node"*, %"union tree_node"*, %"union tree_node"*, i8, i8, i32 }
69%"struct iv_cand" = type { i32, i8, i32, %"union gimple_statement_d"*, %"union tree_node"*, %"union tree_node"*, %"struct iv"*, i32, i32, %"struct iv_use"*, %"struct bitmap_head_def"* }
70%"struct iv_use" = type { i32, i32, %"struct iv"*, %"union gimple_statement_d"*, %"union tree_node"**, %"struct bitmap_head_def"*, i32, %"struct cost_pair"*, %"struct iv_cand"* }
71%"struct ivopts_data" = type { %"struct loop"*, %"struct pointer_map_t"*, i32, i32, %"struct version_info"*, %"struct bitmap_head_def"*, %"struct VEC_iv_use_p_heap"*, %"struct VEC_iv_cand_p_heap"*, %"struct bitmap_head_def"*, i32, i8, i8 }
72%"struct lang_decl" = type opaque
73%"struct language_function" = type opaque
74%"struct loop" = type { i32, i32, %"struct basic_block_def"*, %"struct basic_block_def"*, %"struct comp_cost", i32, i32, %"struct VEC_loop_p_gc"*, %"struct loop"*, %"struct loop"*, i8*, %"union tree_node"*, %"struct double_int", %"struct double_int", i8, i8, i32, %"struct nb_iter_bound"*, %"struct loop_exit"*, i8, %"union tree_node"* }
75%"struct loop_exit" = type { %"struct edge_def"*, %"struct loop_exit"*, %"struct loop_exit"*, %"struct loop_exit"* }
76%"struct loops" = type { i32, %"struct VEC_loop_p_gc"*, %"struct htab"*, %"struct loop"* }
77%"struct machine_cfa_state" = type { %"struct rtx_def"*, i64 }
78%"struct machine_function" = type { %"struct stack_local_entry"*, i8*, i32, i32, %"int[]", i32, %"struct machine_cfa_state", i32, i8 }
79%"struct nb_iter_bound" = type { %"union gimple_statement_d"*, %"struct double_int", i8, %"struct nb_iter_bound"* }
80%"struct object_block" = type { %"union section"*, i32, i64, %"struct VEC_rtx_gc"*, %"struct VEC_rtx_gc"* }
81%"struct obstack" = type { i64, %"struct _obstack_chunk"*, i8*, i8*, i8*, i64, i32, %"struct _obstack_chunk"* (i8*, i64)*, void (i8*, %"struct _obstack_chunk"*)*, i8*, i8 }
82%"struct phi_arg_d" = type { %"struct ssa_use_operand_d", %"union tree_node"*, i32 }
83%"struct pointer_map_t" = type opaque
84%"struct pt_solution" = type { i8, %"struct bitmap_head_def"* }
85%"struct rtx_def" = type { i16, i8, i8, %"union u" }
86%"struct section_common" = type { i32 }
87%"struct ssa_operand_memory_d" = type { %"struct ssa_operand_memory_d"*, %"uchar[]" }
88%"struct ssa_operands" = type { %"struct ssa_operand_memory_d"*, i32, i32, i8, %"struct def_optype_d"*, %"struct use_optype_d"* }
89%"struct ssa_use_operand_d" = type { %"struct ssa_use_operand_d"*, %"struct ssa_use_operand_d"*, %0, %"union tree_node"** }
90%"struct stack_local_entry" = type opaque
91%"struct tree_base" = type <{ i16, i8, i8, i8, [2 x i8], i8 }>
92%"struct tree_common" = type { %"struct tree_base", %"union tree_node"*, %"union tree_node"* }
93%"struct tree_decl_common" = type { %"struct tree_decl_minimal", %"union tree_node"*, i8, i8, i8, i8, i8, i32, %"union tree_node"*, %"union tree_node"*, %"union tree_node"*, %"union tree_node"*, %"struct lang_decl"* }
94%"struct tree_decl_minimal" = type { %"struct tree_common", i32, i32, %"union tree_node"*, %"union tree_node"* }
95%"struct tree_decl_non_common" = type { %"struct tree_decl_with_vis", %"union tree_node"*, %"union tree_node"*, %"union tree_node"*, %"union tree_node"* }
96%"struct tree_decl_with_rtl" = type { %"struct tree_decl_common", %"struct rtx_def"* }
97%"struct tree_decl_with_vis" = type { %"struct tree_decl_with_rtl", %"union tree_node"*, %"union tree_node"*, %"union tree_node"*, i8, i8, i8 }
98%"struct tree_function_decl" = type { %"struct tree_decl_non_common", %"struct function"*, %"union tree_node"*, %"union tree_node"*, %"union tree_node"*, i16, i8, i8 }
99%"struct unnamed_section" = type { %"struct section_common", void (i8*)*, i8*, %"union section"* }
100%"struct use_optype_d" = type { %"struct use_optype_d"*, %"struct ssa_use_operand_d" }
101%"struct version_info" = type { %"union tree_node"*, %"struct iv"*, i8, i32, i8 }
102%"union basic_block_il_dependent" = type { %"struct gimple_bb_info"* }
103%"union edge_def_insns" = type { %"struct gimple_seq_d"* }
104%"union gimple_statement_d" = type { %"struct gimple_statement_phi" }
105%"union rtunion" = type { i8* }
106%"union section" = type { %"struct unnamed_section" }
107%"union tree_node" = type { %"struct tree_function_decl" }
108%"union u" = type { %"struct block_symbol" }
109
110declare fastcc %"union tree_node"* @get_computation_at(%"struct loop"*, %"struct iv_use"* nocapture, %"struct iv_cand"* nocapture, %"union gimple_statement_d"*) nounwind
111
112declare fastcc i32 @computation_cost(%"union tree_node"*, i8 zeroext) nounwind
113
114define fastcc i64 @get_computation_cost_at(%"struct ivopts_data"* %data, %"struct iv_use"* nocapture %use, %"struct iv_cand"* nocapture %cand, i8 zeroext %address_p, %"struct bitmap_head_def"** %depends_on, %"union gimple_statement_d"* %at, i8* %can_autoinc) nounwind {
115entry:
116  br i1 undef, label %"100", label %"4"
117
118"4":                                              ; preds = %entry
119  br i1 undef, label %"6", label %"5"
120
121"5":                                              ; preds = %"4"
122  unreachable
123
124"6":                                              ; preds = %"4"
125  br i1 undef, label %"8", label %"7"
126
127"7":                                              ; preds = %"6"
128  unreachable
129
130"8":                                              ; preds = %"6"
131  br i1 undef, label %"100", label %"10"
132
133"10":                                             ; preds = %"8"
134  br i1 undef, label %"17", label %"16"
135
136"16":                                             ; preds = %"10"
137  unreachable
138
139"17":                                             ; preds = %"10"
140  br i1 undef, label %"19", label %"18"
141
142"18":                                             ; preds = %"17"
143  unreachable
144
145"19":                                             ; preds = %"17"
146  br i1 undef, label %"93", label %"20"
147
148"20":                                             ; preds = %"19"
149  br i1 undef, label %"23", label %"21"
150
151"21":                                             ; preds = %"20"
152  unreachable
153
154"23":                                             ; preds = %"20"
155  br i1 undef, label %"100", label %"25"
156
157"25":                                             ; preds = %"23"
158  br i1 undef, label %"100", label %"26"
159
160"26":                                             ; preds = %"25"
161  br i1 undef, label %"30", label %"28"
162
163"28":                                             ; preds = %"26"
164  unreachable
165
166"30":                                             ; preds = %"26"
167  br i1 undef, label %"59", label %"51"
168
169"51":                                             ; preds = %"30"
170  br i1 undef, label %"55", label %"52"
171
172"52":                                             ; preds = %"51"
173  unreachable
174
175"55":                                             ; preds = %"51"
176  %0 = icmp ugt i32 0, undef                      ; <i1> [#uses=1]
177  br i1 %0, label %"50.i", label %"9.i"
178
179"9.i":                                            ; preds = %"55"
180  unreachable
181
182"50.i":                                           ; preds = %"55"
183  br i1 undef, label %"55.i", label %"54.i"
184
185"54.i":                                           ; preds = %"50.i"
186  br i1 undef, label %"57.i", label %"55.i"
187
188"55.i":                                           ; preds = %"54.i", %"50.i"
189  unreachable
190
191"57.i":                                           ; preds = %"54.i"
192  br label %"63.i"
193
194"61.i":                                           ; preds = %"63.i"
195  br i1 undef, label %"64.i", label %"62.i"
196
197"62.i":                                           ; preds = %"61.i"
198  br label %"63.i"
199
200"63.i":                                           ; preds = %"62.i", %"57.i"
201  br i1 undef, label %"61.i", label %"64.i"
202
203"64.i":                                           ; preds = %"63.i", %"61.i"
204  unreachable
205
206"59":                                             ; preds = %"30"
207  br i1 undef, label %"60", label %"82"
208
209"60":                                             ; preds = %"59"
210  br i1 undef, label %"61", label %"82"
211
212"61":                                             ; preds = %"60"
213  br i1 undef, label %"62", label %"82"
214
215"62":                                             ; preds = %"61"
216  br i1 undef, label %"100", label %"63"
217
218"63":                                             ; preds = %"62"
219  br i1 undef, label %"65", label %"64"
220
221"64":                                             ; preds = %"63"
222  unreachable
223
224"65":                                             ; preds = %"63"
225  br i1 undef, label %"66", label %"67"
226
227"66":                                             ; preds = %"65"
228  unreachable
229
230"67":                                             ; preds = %"65"
231  %1 = load i32, i32* undef, align 4                   ; <i32> [#uses=0]
232  br label %"100"
233
234"82":                                             ; preds = %"61", %"60", %"59"
235  unreachable
236
237"93":                                             ; preds = %"19"
238  %2 = call fastcc %"union tree_node"* @get_computation_at(%"struct loop"* undef, %"struct iv_use"* %use, %"struct iv_cand"* %cand, %"union gimple_statement_d"* %at) nounwind ; <%"union tree_node"*> [#uses=1]
239  br i1 undef, label %"100", label %"97"
240
241"97":                                             ; preds = %"93"
242  br i1 undef, label %"99", label %"98"
243
244"98":                                             ; preds = %"97"
245  br label %"99"
246
247"99":                                             ; preds = %"98", %"97"
248  %3 = phi %"union tree_node"* [ undef, %"98" ], [ %2, %"97" ] ; <%"union tree_node"*> [#uses=1]
249  %4 = call fastcc i32 @computation_cost(%"union tree_node"* %3, i8 zeroext undef) nounwind ; <i32> [#uses=1]
250  br label %"100"
251
252"100":                                            ; preds = %"99", %"93", %"67", %"62", %"25", %"23", %"8", %entry
253  %memtmp1.1.0 = phi i32 [ 0, %"99" ], [ 10000000, %entry ], [ 10000000, %"8" ], [ 10000000, %"23" ], [ 10000000, %"25" ], [ undef, %"62" ], [ undef, %"67" ], [ 10000000, %"93" ] ; <i32> [#uses=1]
254  %memtmp1.0.0 = phi i32 [ %4, %"99" ], [ 10000000, %entry ], [ 10000000, %"8" ], [ 10000000, %"23" ], [ 10000000, %"25" ], [ undef, %"62" ], [ undef, %"67" ], [ 10000000, %"93" ] ; <i32> [#uses=1]
255  %5 = zext i32 %memtmp1.0.0 to i64               ; <i64> [#uses=1]
256  %6 = zext i32 %memtmp1.1.0 to i64               ; <i64> [#uses=1]
257  %7 = shl i64 %6, 32                             ; <i64> [#uses=1]
258  %8 = or i64 %7, %5                              ; <i64> [#uses=1]
259  ret i64 %8
260}
261