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]

[PATCH] Fix final bits of PR28796


This fixes PR28796 as now all related problems are fixed.  It avoids
inconsistent results of folding isinf() and isnan() in the presence
of different math options.

The fix is to use HONOUR_* macros to decide if to fold these.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Ok for mainline?

Thanks,
Richard.

:ADDPATCH middle-end:

2006-08-25  Richard Guenther  <rguenther@suse.de>

	PR middle-end/28796
	* builtins.c (fold_builtin_classify): Use HONOR_INFINITIES
	and HONOR_NANS instead of MODE_HAS_INFINITIES and MODE_HAS_NANS
	for deciding optimizations in consistency with fold-const.c
	(fold_builtin_unordered_cmp): Likewise.

Index: builtins.c
===================================================================
*** builtins.c	(revision 116373)
--- builtins.c	(working copy)
*************** fold_builtin_classify (tree fndecl, tree
*** 8455,8461 ****
    switch (builtin_index)
      {
      case BUILT_IN_ISINF:
!       if (!MODE_HAS_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
  	return omit_one_operand (type, integer_zero_node, arg);
  
        if (TREE_CODE (arg) == REAL_CST)
--- 8455,8461 ----
    switch (builtin_index)
      {
      case BUILT_IN_ISINF:
!       if (!HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
  	return omit_one_operand (type, integer_zero_node, arg);
  
        if (TREE_CODE (arg) == REAL_CST)
*************** fold_builtin_classify (tree fndecl, tree
*** 8471,8478 ****
        return NULL_TREE;
  
      case BUILT_IN_FINITE:
!       if (!MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg)))
! 	  && !MODE_HAS_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
  	return omit_one_operand (type, integer_one_node, arg);
  
        if (TREE_CODE (arg) == REAL_CST)
--- 8471,8478 ----
        return NULL_TREE;
  
      case BUILT_IN_FINITE:
!       if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg)))
! 	  && !HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
  	return omit_one_operand (type, integer_one_node, arg);
  
        if (TREE_CODE (arg) == REAL_CST)
*************** fold_builtin_classify (tree fndecl, tree
*** 8485,8491 ****
        return NULL_TREE;
  
      case BUILT_IN_ISNAN:
!       if (!MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg))))
  	return omit_one_operand (type, integer_zero_node, arg);
  
        if (TREE_CODE (arg) == REAL_CST)
--- 8485,8491 ----
        return NULL_TREE;
  
      case BUILT_IN_ISNAN:
!       if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg))))
  	return omit_one_operand (type, integer_zero_node, arg);
  
        if (TREE_CODE (arg) == REAL_CST)
*************** fold_builtin_unordered_cmp (tree fndecl,
*** 8568,8580 ****
  
    if (unordered_code == UNORDERED_EXPR)
      {
!       if (!MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg0))))
  	return omit_two_operands (type, integer_zero_node, arg0, arg1);
        return fold_build2 (UNORDERED_EXPR, type, arg0, arg1);
      }
  
!   code = MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg0))) ? unordered_code
! 						      : ordered_code;
    return fold_build1 (TRUTH_NOT_EXPR, type,
  		      fold_build2 (code, type, arg0, arg1));
  }
--- 8568,8580 ----
  
    if (unordered_code == UNORDERED_EXPR)
      {
!       if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))))
  	return omit_two_operands (type, integer_zero_node, arg0, arg1);
        return fold_build2 (UNORDERED_EXPR, type, arg0, arg1);
      }
  
!   code = HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))) ? unordered_code
! 						   : ordered_code;
    return fold_build1 (TRUTH_NOT_EXPR, type,
  		      fold_build2 (code, type, arg0, arg1));
  }


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