summaryrefslogtreecommitdiffstats
path: root/gcc
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2002-01-03 17:24:13 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2002-01-03 17:24:13 +0000
commit89558e8804fada5635e277c3f721f3430e285974 (patch)
tree7688e1c97e6e18596cf660ee027a1f4b6c653c20 /gcc
parentf24da1e190edbac03c43d9bef48c8d4a81d6541f (diff)
downloadppe42-gcc-89558e8804fada5635e277c3f721f3430e285974.tar.gz
ppe42-gcc-89558e8804fada5635e277c3f721f3430e285974.zip
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48514 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/simplify-rtx.c9
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/20020103-1.c22
4 files changed, 38 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 38ba6c514f9..ded183f2d0e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,4 +1,10 @@
+2002-01-03 Jakub Jelinek <jakub@redhat.com>
+
+ * simplify-rtx.c (simplify_binary_operation) [DIV]: If
+ gen_lowpart_common fails, use gen_lowpart_SUBREG.
+
2002-01-03 Turly O'Connor <turly@apple.com>
+
* darwin.c (machopic_output_possible_stub_label): Don't generate
stub routines for pseudo-stubs which we've just defined.
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 49c205c5aaa..84209cc0d3d 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -1413,8 +1413,15 @@ simplify_binary_operation (code, mode, op0, op1)
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 (mode != GET_MODE (op0) && GET_MODE (op0) != VOIDmode)
+ return gen_lowpart_SUBREG (mode, op0);
+ else
+ return op0;
}
/* In IEEE floating point, 0/x is not always 0. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0fd97019a9a..18385395bc3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -2,6 +2,8 @@
* g++.dg/other/debug2.C: New test.
+ * gcc.c-torture/compile/20020103-1.c: New test.
+
2002-01-02 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/gnu89-init-1.c: Added new tests.
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020103-1.c b/gcc/testsuite/gcc.c-torture/compile/20020103-1.c
new file mode 100644
index 00000000000..b9861688ddd
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/20020103-1.c
@@ -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;
+}
OpenPOWER on IntegriCloud