This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix another Alpha ICE in if_then_else_cond
- From: Jakub Jelinek <jakub at redhat dot com>
- To: rth at redhat dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 3 Jan 2002 12:54:26 +0100
- Subject: [PATCH] Fix another Alpha ICE in if_then_else_cond
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The following testcase was not fixed by
http://gcc.gnu.org/ml/gcc-patches/2001-12/msg02116.html.
The problem is that gen_lowpart_common fails on:
(ashiftrt:DI (ashift:DI (subreg:DI (div:SI ())))
and simplify_binary_operation failed.
The following patch fixes it.
Or do you prefer instead
/* On some platforms DIV uses narrower mode than its
operands. */
rtx x = gen_lowpart_common (mode, op0);
if (x)
return x;
break;
?
Bootstrap pending.
Ok to commit (the patch or the above modification to it)?
2002-01-03 Jakub Jelinek <jakub@redhat.com>
* simplify-rtx.c (simplify_binary_operation) [DIV]: If
gen_lowpart_common fails, use gen_lowpart_SUBREG.
* gcc.c-torture/compile/20020103-1.c: New test.
--- gcc/testsuite/gcc.c-torture/compile/20020103-1.c.jj Thu Jan 3 13:48:21 2002
+++ gcc/testsuite/gcc.c-torture/compile/20020103-1.c Thu Jan 3 13:48:30 2002
@@ -0,0 +1,22 @@
+/* This testcase failed on Alpha at -O2 when simplifying conditional
+ expressions. */
+
+int foo (void);
+
+struct A
+{
+ int a, b, c, d;
+};
+
+void bar (struct A *x)
+{
+ int e, f;
+
+ e = foo ();
+ e = e / x->b;
+ if (e < 1)
+ e = 1;
+ f = (x->a + x->c) / e;
+ if (f < x->d)
+ x->d -= (1 << 16) / 8;
+}
--- gcc/simplify-rtx.c.jj Sat Dec 29 22:11:41 2001
+++ gcc/simplify-rtx.c Thu Jan 3 13:46:55 2002
@@ -1413,8 +1413,15 @@ simplify_binary_operation (code, mode, o
case DIV:
if (trueop1 == CONST1_RTX (mode))
{
+ /* On some platforms DIV uses narrower mode than its
+ operands. */
rtx x = gen_lowpart_common (mode, op0);
- return x ? x : op0;
+ if (x)
+ return x;
+ else if (GET_MODE (op0) != VOIDmode)
+ return gen_lowpart_SUBREG (mode, op0);
+ else
+ return op0;
}
/* In IEEE floating point, 0/x is not always 0. */
Jakub