On 10/01/2017 02:37 AM, Yuri Gribov wrote:
> Hi all,
> 
> (Previous mail was sent with spurious HTML, sorry!)
> 
> This patch gets rid of float casts in comparisons when all values of
> casted integral type are exactly representable by the float type
> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81376).
> 
> Bootstrapped and regtested on x64_64. Ok to commit?
> 
> -Y
> 
> 
> pr81376-1.patch
> 
> 
> From f6081c8fc1d9c20b686af3f4d8b09a5f60491cba Mon Sep 17 00:00:00 2001
> From: Yury Gribov <tetra2...@gmail.com>
> Date: Fri, 29 Sep 2017 07:34:54 +0200
> Subject: [PATCH] 2017-09-29  Yury Gribov  <tetra2...@gmail.com>
> 
>       PR middle-end/81376
> 
> gcc/
>       * real.c (format_helper::can_represent_integral_type_p): New function
>       * real.h (format_helper::can_represent_integral_type_p): New function.
>       * match.pd: New pattern.
> 
> gcc/testsuite/
>       * c-c++-common/pr81376.c: New test.
> ---
>  gcc/match.pd                         | 45 
> ++++++++++++++++++++++++++++++------
>  gcc/real.c                           | 13 +++++++++++
>  gcc/real.h                           |  1 +
>  gcc/testsuite/c-c++-common/pr81376.c | 39 +++++++++++++++++++++++++++++++
>  4 files changed, 91 insertions(+), 7 deletions(-)
>  create mode 100644 gcc/testsuite/c-c++-common/pr81376.c
> 
> diff --git a/gcc/match.pd b/gcc/match.pd
> index 0863273..863c657 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -2906,6 +2906,42 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>        (if (! HONOR_NANS (@0))
>       (cmp @0 @1))))))
>  
> +/* Optimize various special cases of (FTYPE) N CMP (FTYPE) M.  */
> +(for cmp (lt le eq ne ge gt)
> + (simplify
> +  (cmp (float@0 @1) (float @2))
Since this runs on GENERIC as well as GIMPLE, I don't think you can rely
on the types of the float expressions being the same?!?  Which implies
subsequent code will need and fmt1/fmt2 because you don't know they're
necessarily the same.

Am I missing something?

jeff

Reply via email to