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]

c_common_truthvalue_conversion must handle all comparison exprs


Mainline currently goes into infinite recursion on amd64-linux
compiling one of the probe programs in libstdc++'s configure script:

int main() { __builtin_isgreater(0.0, 0.0); return 0; }

(Only the C++ compiler has this problem.)  We reach gimplify_cond_expr
with a node like this

<cond_expr
   type <void_type void>
   arg 0 <unle_expr
       type <integer_type int>
       constant invariant
       arg 0 <real_cst type <real_type double> 0.0>
       arg 1 <real_cst type <real_type double> 0.0>>
   arg 1 <convert_expr type <void_type void>
       arg 0 <integer_cst 0>>
   arg 2 <convert_expr type <void_type void>
       arg 0 <integer_cst 1>>>

g_c_e sees that the first argument of this has type int, and calles
gimple_boolify to correct that.  gimple_boolify calls
lang_hooks.truthvalue_conversion, which doesn't know what an UNLE_EXPR
is, so it wraps it up in another COND_EXPR with exactly the same form,
then calls gimplify_cond_expr on that.  Lather, rinse, repeat.

The cure is to teach c_common_truthvalue_conversion that UNLE_EXPR
(and all the other unordered comparisons) should be handled the way
EQ_EXPR etc are already handled, i.e. by overwriting the type with
truthvalue_type_node and returning.

Thanks to Andrew Pinski for help debugging this.  Bootstrapped
amd64-linux.

zw

        * c-common.c (c_common_truthvalue_conversion): Handle
        UNEQ_EXPR, UNLE_EXPR, UNGE_EXPR, UNLT_EXPR, UNGT_EXPR,
        ORDERED_EXPR, and UNORDERED_EXPR as comparison operators,
        i.e. set the type to truthvalue_type_node and return.

===================================================================
Index: c-common.c
--- c-common.c	18 May 2004 01:26:05 -0000	1.500
+++ c-common.c	22 May 2004 17:52:34 -0000
@@ -2582,8 +2582,10 @@ c_common_truthvalue_conversion (tree exp
 
   switch (TREE_CODE (expr))
     {
-    case EQ_EXPR:
-    case NE_EXPR: case LE_EXPR: case GE_EXPR: case LT_EXPR: case GT_EXPR:
+    case EQ_EXPR:   case NE_EXPR:   case UNEQ_EXPR:
+    case LE_EXPR:   case GE_EXPR:   case LT_EXPR:   case GT_EXPR:
+    case UNLE_EXPR: case UNGE_EXPR: case UNLT_EXPR: case UNGT_EXPR:
+    case ORDERED_EXPR: case UNORDERED_EXPR:
     case TRUTH_ANDIF_EXPR:
     case TRUTH_ORIF_EXPR:
     case TRUTH_AND_EXPR:


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