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

--- Comment #8 from Marc Glisse <glisse at gcc dot gnu.org> ---
Created attachment 45306
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45306&action=edit
ix86_gimple_fold_builtin patch

Like this then?

I realized (because of the testsuite) that we do not currently validate that
the 3rd argument is a 2-bit immediate (the error message on non-constants is
misleading), and Intel's documentation indeed seems to indicate that any
integer is valid, we only look at the 2 lowest bits.

If possible, I think it would be nice to reduce the number of builtins, that's
why I started with a patch to emmintrin.h (I now know that it should use
(mask&2)?3:2 for the second number). For validation, something like:

  if(!__builtin_constant_p(__mask)) complain();

with

extern void complain(void) __attribute__((error("argument must be a
constant")));

may be good enough. But we still need to handle -O0... Yeah, maybe
ix86_gimple_fold_builtin is easier :-(

Reply via email to