Richard Sandiford <richard.sandif...@arm.com> writes: >> @@ -992,21 +1029,27 @@ vect_recog_dot_prod_pattern (vec_info *vinfo, >> /* FORNOW. Can continue analyzing the def-use chain when this stmt in a >> phi >> inside the loop (in case we are analyzing an outer-loop). */ >> vect_unpromoted_value unprom0[2]; >> + enum optab_subtype subtype = optab_vector; >> if (!vect_widened_op_tree (vinfo, mult_vinfo, MULT_EXPR, WIDEN_MULT_EXPR, >> - false, 2, unprom0, &half_type)) >> + false, 2, unprom0, &half_type, &subtype)) >> + return NULL; >> + >> + if (subtype == optab_vector_mixed_sign >> + && TYPE_UNSIGNED (unprom_mult.type) >> + && TYPE_PRECISION (half_type) * 4 > TYPE_PRECISION (unprom_mult.type)) >> return NULL; > > Isn't the final condition here instead that TYPE1 is narrower than TYPE2? > I.e. we need to reject the case in which we multiply a signed and an > unsigned value to get a (logically) signed result, but then zero-extend > it (rather than sign-extend it) to the precision of the addition. > > That would make the test: > > if (subtype == optab_vector_mixed_sign > && TYPE_UNSIGNED (unprom_mult.type) > && TYPE_PRECISION (unprom_mult.type) < TYPE_PRECISION (type)) > return NULL; > > instead.
And folding that into the existing test gives: /* If there are two widening operations, make sure they agree on the sign of the extension. The result of an optab_vector_mixed_sign operation is signed; otherwise, the result has the same sign as the operands. */ if (TYPE_PRECISION (unprom_mult.type) != TYPE_PRECISION (type) && (subtype == optab_vector_mixed_sign ? TYPE_UNSIGNED (unprom_mult.type) : TYPE_SIGN (unprom_mult.type) != TYPE_SIGN (half_type))) return NULL; Thanks, Richard