This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix ICE in chrec_convert_1
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 15 Dec 2009 17:51:58 -0500
- Subject: [PATCH] Fix ICE in chrec_convert_1
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The PR34163 fix caused a regression on the testcase below, build2 (PLUS_EXPR, ...)
is called with POINTER_TYPE_P types of both arguments and the result type.
This is on a
y_N = z_N + 1;
x_N = (char *) y_N;
where [yz]_N have int type and x_N is char *.
The following patch fixes it, bootstrapped/regtested on x86_64-linux. Ok
for trunk?
2009-12-15 Jakub Jelinek <jakub@redhat.com>
* tree-chrec.c (chrec_convert_1): Only fold (T2)(t +- x) to
(T2)t +- (T2)x if only integer types are involved.
* gcc.c-torture/compile/20091215-1.c: New test.
--- gcc/tree-chrec.c.jj 2009-11-25 16:47:35.000000000 +0100
+++ gcc/tree-chrec.c 2009-12-15 19:34:15.000000000 +0100
@@ -1293,6 +1293,8 @@ keep_cast:
if (use_overflow_semantics
&& (TREE_CODE (chrec) == PLUS_EXPR
|| TREE_CODE (chrec) == MINUS_EXPR)
+ && TREE_CODE (type) == INTEGER_TYPE
+ && TREE_CODE (ct) == INTEGER_TYPE
&& TYPE_PRECISION (type) > TYPE_PRECISION (ct)
&& TYPE_OVERFLOW_UNDEFINED (ct))
res = fold_build2 (TREE_CODE (chrec), type,
--- gcc/testsuite/gcc.c-torture/compile/20091215-1.c.jj 2009-12-15 23:45:09.000000000 +0100
+++ gcc/testsuite/gcc.c-torture/compile/20091215-1.c 2009-12-15 19:04:41.000000000 +0100
@@ -0,0 +1,15 @@
+void bar ();
+
+void
+foo (void *x, short y)
+{
+ bar (x, y + 1);
+}
+
+void
+bar (x, y)
+ void *x;
+ char *y;
+{
+ baz (y);
+}
Jakub