public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* ORDERED_EXPR in invert_tree_comparison
@ 2012-07-19 15:52 Marc Glisse
  2012-08-01 19:21 ` Marc Glisse
  0 siblings, 1 reply; 8+ messages in thread
From: Marc Glisse @ 2012-07-19 15:52 UTC (permalink / raw)
  To: gcc-patches

Hello,

the simple patch below passes the testsuite after a c,c++ bootstrap 
without new regressions. Note however that

#include <math.h>
int f(double a, double b){
   return (!isunordered(a,b))&&(a<b);
}

is then optimized by ifcombine to "return (a<b);", which seems wrong in 
the absence of -fno-trapping-math. I don't know if there are ways to 
trigger this latent bug without the patch.



2012-06-15  Marc Glisse  <marc.glisse@inria.fr>

         PR tree-optimization/53805
         * fold-const.c (invert_tree_comparison): Do invert ORDERED_EXPR and
         UNORDERED_EXPR for floating point.

--- fold-const.c	(revision 189622)
+++ fold-const.c	(working copy)
@@ -2096,13 +2096,14 @@ pedantic_non_lvalue_loc (location_t loc,
     It is generally not safe to do this for floating-point comparisons, except
     for EQ_EXPR and NE_EXPR, so we return ERROR_MARK in this case.  */

  enum tree_code
  invert_tree_comparison (enum tree_code code, bool honor_nans)
  {
-  if (honor_nans && flag_trapping_math && code != EQ_EXPR && code != NE_EXPR)
+  if (honor_nans && flag_trapping_math && code != EQ_EXPR && code != NE_EXPR
+      && code != ORDERED_EXPR && code != UNORDERED_EXPR)
      return ERROR_MARK;

    switch (code)
      {
      case EQ_EXPR:
        return NE_EXPR;

-- 
Marc Glisse

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-08-02 15:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-19 15:52 ORDERED_EXPR in invert_tree_comparison Marc Glisse
2012-08-01 19:21 ` Marc Glisse
2012-08-02  8:51   ` Richard Guenther
2012-08-02 12:48     ` Marc Glisse
2012-08-02 13:37       ` Richard Guenther
2012-08-02 13:56       ` Nathan Froyd
2012-08-02 15:20         ` Marc Glisse
2012-08-02 15:24           ` Nathan Froyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).