[Bug target/57009] Select best typed instruction for scalar bitwise operations

glisse at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Apr 20 13:00:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57009

--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> 2013-04-20 13:00:48 UTC ---
At least in the case where a constant is involved, it would probably be
necessary to look at how the result is used (makes it much harder). If it is
used in a floating point operation, doing the logic operation in the FPU is
better. If it is used in an integer operation, it is probably better to let the
ALU handle it:

union A { double d; unsigned long long i; };
bool f(double x){
  A a; a.d = x;
  unsigned long long inf = 0x7ff0000000000000;
  return (a.i & inf) != inf;
}

(I use != and not < in the example above because gcc insists on creating a new
constant inf-1 and replacing <inf with <=inf-1)



More information about the Gcc-bugs mailing list