Hi!

On Thu, Mar 05, 2020 at 10:46:58AM +0800, Jiufu Guo wrote:
> PR93709 mentioned regressions on maxlocval_4.f90 and minlocval_f.f90 which
> relates to max of '-inf' and 'nan'. This regression occur on P9 which has
> new instruction 'xsmaxcdp/xsmincdp'.
> The similar issue also could be find on `a < b ? b : a` which is also
> generated as `xsmaxcdp` under -O2 for P9. This instruction `xsmaxcdp`
> more like C/C++ semantic (a>b?a:b). A testcase is added for this issue.
> 
> The following patch improve code to check -+0 and NaN before 'smax/smin' to
> be generated for those cases.

> -  else if (rtx_equal_p (op1, true_cond) && rtx_equal_p (op0, false_cond))
> +  /* Only when -fno-signed-zeros and -ffinite_math_only are in effect,
> +     `op0 < op1 ? op1 : op0` works like `op1 > op0 ? op1 : op0` which 
> +     could use smax;
> +     `op0 > op1 ? op1 : op0` works like `op1 < op0 ? op1 : op0` which
> +     could use smin.  */
> +  else if (rtx_equal_p (op1, true_cond) && rtx_equal_p (op0, false_cond)
> +        && (flag_finite_math_only && !flag_signed_zeros))
>      max_p = !max_p;

I know I asked for it, but should this use HONOR_NANS (compare_mode)
instead?  Infinities will work fine?  Just NaNs and zeros won't.

Okay for trunk with that change (if it works :-) )  Thanks!


Segher

Reply via email to