This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PR57371] transform (double)i eq/ne 0 to i eq/ne 0


On Wed, 3 Aug 2016, Prathamesh Kulkarni wrote:

> Hi,
> The attached patch tries to transform
> (double)i eq/ne 0 to i eq/ne 0
> AFAIU from Joseph's comment 1 in PR, the transform should be safe with
> -fno-trapping-math ?
> Bootstrap+tested on x86_64-unknown-linux-gnu in progress.

Couldn't this even be

 (cmp (float @0) REAL_CST@1)
 (with
  {
    HOST_WIDE_INT n = real_to_integer (TREE_REAL_CST (@1));
    REAL_VALUE_TYPE cint;
    real_from_integer (&cint, VOIDmode, n, SIGNED);
  }
  (if (real_identical (&c, &cint))
   (cmp @0 { build_int_cst (TREE_TYPE (@0), n); }))))

with some additional type checks to make sure n fits the type of @0
(and otherwise fold to true/false directly).

Not sure whether we need to restrict it to float types that can
represent all values of the type of @0 exactly.

Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]