https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85323

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-04-10
                 CC|                            |hjl.tools at gmail dot com,
                   |                            |itsimbal at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org,
                   |                            |jkoval at gcc dot gnu.org,
                   |                            |kyukhin at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The builtins have different behavior from the C shifts on vectors, where shift
counts < 0 or >= element bitsize are just undefined.

What the i386 backend could do (and should do) is extend ix86_fold_builtin
and/or ix86_gimple_fold_builtin to optimize these builtins.

For the shifts in particular, if the shift count (treated as unsigned) is equal
to the element size or larger, return a zero vector, and if it is 0, return the
first operand, or if first argument is VECTOR_CST and second argument is
INTEGER_CST, compute it into VECTOR_CST.  Similarly for VECTOR_CST second
operand, handle the VECTOR_CST, VECTOR_CST operands, or when all elts of the
latter one are equal, or all are >= element size.  Many other MD builtins
should be folded too.

Reply via email to