Lines 182-187
static struct
Link Here
|
182 |
/* Number of widening multiplication ops inserted. */ |
182 |
/* Number of widening multiplication ops inserted. */ |
183 |
int widen_mults_inserted; |
183 |
int widen_mults_inserted; |
184 |
|
184 |
|
|
|
185 |
/* Number of highpart multiplication ops inserted. */ |
186 |
int highpart_mults_inserted; |
187 |
|
185 |
/* Number of integer multiply-and-accumulate ops inserted. */ |
188 |
/* Number of integer multiply-and-accumulate ops inserted. */ |
186 |
int maccs_inserted; |
189 |
int maccs_inserted; |
187 |
|
190 |
|
Lines 3145-3150
convert_mult_to_widen (gimple *stmt, gim
Link Here
|
3145 |
else |
3148 |
else |
3146 |
op = usmul_widen_optab; |
3149 |
op = usmul_widen_optab; |
3147 |
|
3150 |
|
|
|
3151 |
/* Detect extraction of the highpart of the multiply and use h* |
3152 |
instead of w* in that case. E.g. |
3153 |
_1 = (long long unsigned int) x_4; |
3154 |
_2 = _1 * 6700417; |
3155 |
_3 = _2 >> 32; |
3156 |
_5 = (unsigned int) _3; |
3157 |
can be optimized into: |
3158 |
_5 = x_4 h* 6700417; */ |
3159 |
use_operand_p use1_p, use2_p; |
3160 |
gimple *use1_stmt, *use2_stmt; |
3161 |
if (from_unsigned1 == from_unsigned2 |
3162 |
&& TREE_CODE (rhs1) != INTEGER_CST |
3163 |
&& TYPE_PRECISION (type1) * 2 == TYPE_PRECISION (type) |
3164 |
&& GET_MODE_PRECISION (from_mode) == TYPE_PRECISION (type1) |
3165 |
&& GET_MODE_PRECISION (to_mode) == TYPE_PRECISION (type) |
3166 |
&& single_imm_use (lhs, &use1_p, &use1_stmt) |
3167 |
&& is_gimple_assign (use1_stmt) |
3168 |
&& gimple_assign_rhs_code (use1_stmt) == RSHIFT_EXPR |
3169 |
&& tree_fits_uhwi_p (gimple_assign_rhs2 (use1_stmt)) |
3170 |
&& tree_to_uhwi (gimple_assign_rhs2 (use1_stmt)) == TYPE_PRECISION (type1) |
3171 |
&& single_imm_use (gimple_assign_lhs (use1_stmt), &use2_p, &use2_stmt) |
3172 |
&& gimple_assign_cast_p (use2_stmt)) |
3173 |
{ |
3174 |
tree lhs2 = gimple_assign_lhs (use2_stmt); |
3175 |
if (INTEGRAL_TYPE_P (TREE_TYPE (lhs2)) |
3176 |
&& TYPE_PRECISION (TREE_TYPE (lhs2)) == TYPE_PRECISION (type1) |
3177 |
&& optab_handler (from_unsigned1 |
3178 |
? umul_highpart_optab : smul_highpart_optab, |
3179 |
from_mode) != CODE_FOR_nothing) |
3180 |
{ |
3181 |
gimple_stmt_iterator gsi2 = gsi_for_stmt (use2_stmt); |
3182 |
gimple_seq stmts = NULL; |
3183 |
|
3184 |
if (TREE_CODE (rhs2) == INTEGER_CST) |
3185 |
rhs2 = fold_convert (type1, rhs2); |
3186 |
else if (TYPE_PRECISION (type2) != TYPE_PRECISION (type1)) |
3187 |
rhs2 = build_and_insert_cast (&gsi2, loc, type1, rhs2); |
3188 |
tree highpart = gimple_build (&stmts, MULT_HIGHPART_EXPR, |
3189 |
type1, rhs1, rhs2); |
3190 |
gsi_insert_seq_before (&gsi2, stmts, GSI_SAME_STMT); |
3191 |
gimple_assign_set_rhs1 (use2_stmt, highpart); |
3192 |
if (useless_type_conversion_p (TREE_TYPE (lhs2), type1)) |
3193 |
gimple_assign_set_rhs_code (use2_stmt, TREE_CODE (highpart)); |
3194 |
update_stmt (use2_stmt); |
3195 |
widen_mul_stats.highpart_mults_inserted++; |
3196 |
return true; |
3197 |
} |
3198 |
} |
3199 |
|
3148 |
handler = find_widening_optab_handler_and_mode (op, to_mode, from_mode, |
3200 |
handler = find_widening_optab_handler_and_mode (op, to_mode, from_mode, |
3149 |
0, &actual_mode); |
3201 |
0, &actual_mode); |
3150 |
|
3202 |
|
Lines 4141-4146
pass_optimize_widening_mul::execute (fun
Link Here
|
4141 |
|
4193 |
|
4142 |
statistics_counter_event (fun, "widening multiplications inserted", |
4194 |
statistics_counter_event (fun, "widening multiplications inserted", |
4143 |
widen_mul_stats.widen_mults_inserted); |
4195 |
widen_mul_stats.widen_mults_inserted); |
|
|
4196 |
statistics_counter_event (fun, "highpart multiplications inserted", |
4197 |
widen_mul_stats.highpart_mults_inserted); |
4144 |
statistics_counter_event (fun, "widening maccs inserted", |
4198 |
statistics_counter_event (fun, "widening maccs inserted", |
4145 |
widen_mul_stats.maccs_inserted); |
4199 |
widen_mul_stats.maccs_inserted); |
4146 |
statistics_counter_event (fun, "fused multiply-adds inserted", |
4200 |
statistics_counter_event (fun, "fused multiply-adds inserted", |