[gcc r17-3229] vect: For now restrict vect_validate_multiplication_commutative to only 4 forms [PR126589]
Tamar Christina via Gcc-cvs <[email protected]>
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:2e722bc990f8a64ad80e2f6a565ef1d5f206a7e0 commit r17-3229-g2e722bc990f8a64ad80e2f6a565ef1d5f206a7e0 Author: Tamar Christina <[email protected]> Date: Wed Aug 12 14:16:12 2026 +0100 vect: For now restrict vect_validate_multiplication_commutative to only 4 forms [PR126589] Flipping the order of the operands can end up changing the sign of the operation and to compensate an adjustment operation has to be inserted (i.e. * {-1,1}). The current code in trunk cannot do this yet so backporting the change from my complex numbers branch caused it to produce incorrect code. For now while the full changes aren't upstreamed remove the last 4 swaps. gcc/ChangeLog: PR tree-optimization/126589 * tree-vect-slp-patterns.cc (vect_validate_multiplication): Cleanup comment. (vect_validate_multiplication_commutative): Remove last 4 orders. Diff: --- gcc/tree-vect-slp-patterns.cc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/gcc/tree-vect-slp-patterns.cc b/gcc/tree-vect-slp-patterns.cc index aae000ee5292..8a03a25475da 100644 --- a/gcc/tree-vect-slp-patterns.cc +++ b/gcc/tree-vect-slp-patterns.cc @@ -933,9 +933,8 @@ vect_validate_multiplication (slp_tree_to_load_perm_map_t *perm_cache, /* Try to validate LEFT_OP and RIGHT_OP as the operands of a complex multiplication. Since MULT_EXPR is commutative, try all combinations of - swapping the operands of each multiplication and both orders of the two - multiplies. If a match is found, set OPS and STATUS for the matching - order. */ + swapping the operands of each multiplication. If a match is found, set OPS + and STATUS for the matching order. */ static inline bool vect_validate_multiplication_commutative (slp_tree_to_load_perm_map_t *perm_cache, @@ -951,18 +950,13 @@ vect_validate_multiplication_commutative (slp_tree_to_load_perm_map_t *perm_cach { 0, 1, 3, 2 }, /* (L0 * L1), (R1 * R0). */ { 1, 0, 2, 3 }, /* (L1 * L0), (R0 * R1). */ { 1, 0, 3, 2 }, /* (L1 * L0), (R1 * R0). */ - { 2, 3, 0, 1 }, /* (R0 * R1), (L0 * L1). */ - { 2, 3, 1, 0 }, /* (R0 * R1), (L1 * L0). */ - { 3, 2, 0, 1 }, /* (R1 * R0), (L0 * L1). */ - { 3, 2, 1, 0 }, /* (R1 * R0), (L1 * L0). */ }; - /* The first four entries only swap operands within each MULT_EXPR. - The remaining entries also swap the two product terms, which is not - valid for plain subtraction. */ - unsigned nperms = subtract ? 4 : ARRAY_SIZE (op_indices); + /* Only try permutations that swap operands within each MULT_EXPR. Swapping + the two product terms is not valid because the real lane is ordered by a + subtraction. */ slp_tree all_ops[4] = { left_op[0], left_op[1], right_op[0], right_op[1] }; - for (unsigned i = 0; i < nperms; ++i) + for (unsigned i = 0; i < ARRAY_SIZE (op_indices); ++i) { auto_vec<slp_tree> trial_ops; if (vect_validate_multiplication (perm_cache, compat_cache, all_ops,