@@ -45,7 +45,7 @@ impl<'a> ValueMerger<'a> {
45
45
46
46
/// Merge two values a and b from separate basic blocks to a single value.
47
47
/// If these two values are numeric, the result will be
48
- /// `then_condition * then_value + else_condition * else_value`.
48
+ /// `then_condition * ( then_value - else_value) + else_value`.
49
49
/// Otherwise, if the values being merged are arrays, a new array will be made
50
50
/// recursively from combining each element of both input arrays.
51
51
///
@@ -54,7 +54,6 @@ impl<'a> ValueMerger<'a> {
54
54
pub ( crate ) fn merge_values (
55
55
& mut self ,
56
56
then_condition : ValueId ,
57
- else_condition : ValueId ,
58
57
then_value : ValueId ,
59
58
else_value : ValueId ,
60
59
) -> ValueId {
@@ -70,28 +69,26 @@ impl<'a> ValueMerger<'a> {
70
69
self . dfg ,
71
70
self . block ,
72
71
then_condition,
73
- else_condition,
74
72
then_value,
75
73
else_value,
76
74
) ,
77
75
typ @ Type :: Array ( _, _) => {
78
- self . merge_array_values ( typ, then_condition, else_condition , then_value, else_value)
76
+ self . merge_array_values ( typ, then_condition, then_value, else_value)
79
77
}
80
78
typ @ Type :: Slice ( _) => {
81
- self . merge_slice_values ( typ, then_condition, else_condition , then_value, else_value)
79
+ self . merge_slice_values ( typ, then_condition, then_value, else_value)
82
80
}
83
81
Type :: Reference ( _) => panic ! ( "Cannot return references from an if expression" ) ,
84
82
Type :: Function => panic ! ( "Cannot return functions from an if expression" ) ,
85
83
}
86
84
}
87
85
88
86
/// Merge two numeric values a and b from separate basic blocks to a single value. This
89
- /// function would return the result of `if c { a } else { b }` as `c*a + (!c)* b`.
87
+ /// function would return the result of `if c { a } else { b }` as `c * (a-b) + b`.
90
88
pub ( crate ) fn merge_numeric_values (
91
89
dfg : & mut DataFlowGraph ,
92
90
block : BasicBlockId ,
93
91
then_condition : ValueId ,
94
- _else_condition : ValueId ,
95
92
then_value : ValueId ,
96
93
else_value : ValueId ,
97
94
) -> ValueId {
@@ -155,7 +152,6 @@ impl<'a> ValueMerger<'a> {
155
152
& mut self ,
156
153
typ : Type ,
157
154
then_condition : ValueId ,
158
- else_condition : ValueId ,
159
155
then_value : ValueId ,
160
156
else_value : ValueId ,
161
157
) -> ValueId {
@@ -170,7 +166,6 @@ impl<'a> ValueMerger<'a> {
170
166
171
167
if let Some ( result) = self . try_merge_only_changed_indices (
172
168
then_condition,
173
- else_condition,
174
169
then_value,
175
170
else_value,
176
171
actual_length,
@@ -200,12 +195,7 @@ impl<'a> ValueMerger<'a> {
200
195
let then_element = get_element ( then_value, typevars. clone ( ) ) ;
201
196
let else_element = get_element ( else_value, typevars) ;
202
197
203
- merged. push_back ( self . merge_values (
204
- then_condition,
205
- else_condition,
206
- then_element,
207
- else_element,
208
- ) ) ;
198
+ merged. push_back ( self . merge_values ( then_condition, then_element, else_element) ) ;
209
199
}
210
200
}
211
201
@@ -216,7 +206,6 @@ impl<'a> ValueMerger<'a> {
216
206
& mut self ,
217
207
typ : Type ,
218
208
then_condition : ValueId ,
219
- else_condition : ValueId ,
220
209
then_value_id : ValueId ,
221
210
else_value_id : ValueId ,
222
211
) -> ValueId {
@@ -274,12 +263,7 @@ impl<'a> ValueMerger<'a> {
274
263
let else_element =
275
264
get_element ( else_value_id, typevars, else_len * element_types. len ( ) ) ;
276
265
277
- merged. push_back ( self . merge_values (
278
- then_condition,
279
- else_condition,
280
- then_element,
281
- else_element,
282
- ) ) ;
266
+ merged. push_back ( self . merge_values ( then_condition, then_element, else_element) ) ;
283
267
}
284
268
}
285
269
@@ -322,7 +306,6 @@ impl<'a> ValueMerger<'a> {
322
306
fn try_merge_only_changed_indices (
323
307
& mut self ,
324
308
then_condition : ValueId ,
325
- else_condition : ValueId ,
326
309
then_value : ValueId ,
327
310
else_value : ValueId ,
328
311
array_length : usize ,
@@ -406,8 +389,7 @@ impl<'a> ValueMerger<'a> {
406
389
let then_element = get_element ( then_value, typevars. clone ( ) ) ;
407
390
let else_element = get_element ( else_value, typevars) ;
408
391
409
- let value =
410
- self . merge_values ( then_condition, else_condition, then_element, else_element) ;
392
+ let value = self . merge_values ( then_condition, then_element, else_element) ;
411
393
412
394
array = self . insert_array_set ( array, index, value, Some ( condition) ) . first ( ) ;
413
395
}
0 commit comments