Patchwork Fix comparison type in builtin folding

login
register
mail settings
Submitter Richard Guenther
Date July 29, 2011, 9:56 a.m.
Message ID <alpine.LNX.2.00.1107291155270.810@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/107362/
State New
Headers show

Comments

Richard Guenther - July 29, 2011, 9:56 a.m.
I noticed the following when LTOing libgfortran into polyhedron
with -Ofast which delays signbit folding and exposes the bogus
comparison type to the new stricter type checking.

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

Richard.

2011-07-29  Richard Guenther  <rguenther@suse.de>

	* builtins.c (fold_builtin_signbit): Build the comparison
	with a proper type.

Patch

Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	(revision 176920)
+++ gcc/builtins.c	(working copy)
@@ -8645,8 +8645,9 @@  fold_builtin_signbit (location_t loc, tr
 
   /* If ARG's format doesn't have signed zeros, return "arg < 0.0".  */
   if (!HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg))))
-    return fold_build2_loc (loc, LT_EXPR, type, arg,
-			build_real (TREE_TYPE (arg), dconst0));
+    return fold_convert (type,
+			 fold_build2_loc (loc, LT_EXPR, boolean_type_node, arg,
+			build_real (TREE_TYPE (arg), dconst0)));
 
   return NULL_TREE;
 }