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] Revert part of my commit from yesterday (fix PR c++/20023, tree-optimization/20009)


Hi!

The convert.c part of the patch to PR middle-end/19857 fix was not
strictly necessary and although it did not cause any make check regressions on
any of the 7 arches I used to bootstrap/regtest, it apparently caused some
failures.
E.g. in c++/20023 case, the difference is that the switch condition
used to look like:
<nop_expr (size_t) <convert_expr (int) <param_decl (pointer) >>>
which folds into itself and therefore expand_case sees an integer
SWITCH_COND.  But with my convert.c change convert_to_integer
returns <nop_expr (size_t) <convert_expr (unsigned int) <param_decl (pointer) >>>
and as fold strips sign nops, it folds this into
<nop_expr (size_t) <param_decl (pointer) >>.
I believe it is not wrong even at this point, converting from pointer
to size_t does not at least on i386-*-linux* need any runtime code and
therefore I think a NOP_EXPR is appropriate.  But e.g. expand_case
is not prepared to see POINTER_TYPE's after stripping nops.
Given how close we are to 4.0 branching, I think best is to revert
this part of my patch and perhaps look into this in the future.
Ok?

2005-02-17  Jakub Jelinek  <jakub@redhat.com>

	PR c++/20023
	PR tree-optimization/20009
	* convert.c (convert_to_integer): Revert 2005-02-16 change.

	* gcc.c-torture/compile/20050217-1.c: New test.
	* g++.dg/opt/switch3.C: New test.

--- gcc/convert.c.jj	2005-02-16 14:52:36.000000000 +0100
+++ gcc/convert.c	2005-02-17 15:38:03.307819471 +0100
@@ -387,8 +387,7 @@ convert_to_integer (tree type, tree expr
 	expr = integer_zero_node;
       else
 	expr = fold (build1 (CONVERT_EXPR,
-			     lang_hooks.types.type_for_size
-				(POINTER_SIZE, TYPE_UNSIGNED (type)),
+			     lang_hooks.types.type_for_size (POINTER_SIZE, 0),
 			     expr));
 
       return convert_to_integer (type, expr);
--- gcc/testsuite/gcc.c-torture/compile/20050217-1.c	2005-01-27 14:27:08.338732320 +0100
+++ gcc/testsuite/gcc.c-torture/compile/20050217-1.c	2005-02-17 15:10:08.702023097 +0100
@@ -0,0 +1,14 @@
+/* PR c++/20023 */
+
+void f (void);
+typedef __SIZE_TYPE__ size_t;
+void g (void *a)
+{
+  size_t b = (size_t) a;
+  switch (b)
+  {
+    case 1:
+    f ();
+    break;
+  }
+}
--- gcc/testsuite/g++.dg/opt/switch3.C	2005-01-27 14:27:08.338732320 +0100
+++ gcc/testsuite/g++.dg/opt/switch3.C	2005-02-17 15:10:08.702023097 +0100
@@ -0,0 +1,16 @@
+// PR c++/20023
+// { dg-do compile }
+// { dg-options "-O2" }
+
+void f (void);
+typedef __SIZE_TYPE__ size_t;
+void g (void *a)
+{
+  size_t b = (size_t) a;
+  switch (b)
+  {
+    case 1:
+    f ();
+    break;
+  }
+}

	Jakub


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