Hi! As the testcase shows, while reassociation of vector multiplication has been enabled, the eliminate_using_constants optimization isn't enabled for integral vectors (only for floating point vectors), so e.g. if we have more than one { ~0, ~0, ... } vectors in there coming from NEGATE_EXPRs, we don't actually fold them into a single { ~0, ~0, ... } or { 1, 1, ... } vector (the former then into NEGATE_EXPR on the result, the latter removed altogether).
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-10-31 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/77860 * tree-ssa-reassoc.c (eliminate_using_constants): Handle also integral complex and vector constants. * gcc.dg/pr77860.c: New test. --- gcc/tree-ssa-reassoc.c.jj 2016-10-31 13:28:12.000000000 +0100 +++ gcc/tree-ssa-reassoc.c 2016-10-31 13:47:00.364216248 +0100 @@ -924,7 +924,7 @@ eliminate_using_constants (enum tree_cod tree type = TREE_TYPE (oelast->op); if (oelast->rank == 0 - && (INTEGRAL_TYPE_P (type) || FLOAT_TYPE_P (type))) + && (ANY_INTEGRAL_TYPE_P (type) || FLOAT_TYPE_P (type))) { switch (opcode) { --- gcc/testsuite/gcc.dg/pr77860.c.jj 2016-10-31 13:50:34.019649814 +0100 +++ gcc/testsuite/gcc.dg/pr77860.c 2016-10-31 13:49:35.000000000 +0100 @@ -0,0 +1,13 @@ +/* PR tree-optimization/77860 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-vrp -fno-tree-forwprop -Wno-psabi" } */ + +typedef unsigned short V __attribute__((vector_size (16))); + +V +foo (V x, V y) +{ + V a = -x; + V b = -y; + return a * b; +} Jakub