aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2001-12-20 09:26:20 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2001-12-20 09:26:20 +0100
commita9dc868ffb3fb50e9214823c322cab7c6cf72e30 (patch)
treeea0ef2f6d06f6f68479430c907804e9f4ea87dd4 /gcc
parent2a3b43b609ca4f3850226eecb5fec29f1ab80d35 (diff)
downloadgcc-a9dc868ffb3fb50e9214823c322cab7c6cf72e30.zip
gcc-a9dc868ffb3fb50e9214823c322cab7c6cf72e30.tar.gz
gcc-a9dc868ffb3fb50e9214823c322cab7c6cf72e30.tar.bz2
simplify-rtx.c (simplifi_binary_operation): If DIV has narrower mode than op0, only return the bits in DIV's mode.
* simplify-rtx.c (simplifi_binary_operation) [DIV]: If DIV has narrower mode than op0, only return the bits in DIV's mode. * gcc.c-torture/compile/20011219-2.c: New test. From-SVN: r48199
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/simplify-rtx.c5
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/20011219-2.c20
4 files changed, 31 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f1634cc..0f25ad6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2001-12-20 Jakub Jelinek <jakub@redhat.com>
+ * simplify-rtx.c (simplifi_binary_operation) [DIV]: If DIV has
+ narrower mode than op0, only return the bits in DIV's mode.
+
+2001-12-20 Jakub Jelinek <jakub@redhat.com>
+
* combine.c (distribute_notes): Avoid adding REG_LABEL notes
to JUMP_INSNs with JUMP_LABEL.
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 122768e..2b25d9c 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -1412,7 +1412,10 @@ simplify_binary_operation (code, mode, op0, op1)
case DIV:
if (trueop1 == CONST1_RTX (mode))
- return op0;
+ {
+ rtx x = gen_lowpart_common (mode, op0);
+ return x ? x : op0;
+ }
/* In IEEE floating point, 0/x is not always 0. */
if ((TARGET_FLOAT_FORMAT != IEEE_FLOAT_FORMAT
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index de0cdf8..aaee1d5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,7 @@
2001-12-20 Jakub Jelinek <jakub@redhat.com>
+ * gcc.c-torture/compile/20011219-2.c: New test.
+
* gcc.c-torture/execute/20011219-1.c: New test.
2001-12-19 David Billinghurst <David.Billinghurst@riotinto.com>
diff --git a/gcc/testsuite/gcc.c-torture/compile/20011219-2.c b/gcc/testsuite/gcc.c-torture/compile/20011219-2.c
new file mode 100644
index 0000000..2ad7eb1
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/20011219-2.c
@@ -0,0 +1,20 @@
+/* This testcase failed on Alpha at -O2 when simplifying conditional
+ expressions. */
+
+struct S {
+ unsigned long a;
+ double b, c;
+};
+
+extern double bar (double, double);
+
+int
+foo (unsigned long x, unsigned int y, struct S *z)
+{
+ unsigned int a = z->a;
+ int b = y / z->a > 1 ? y / z->a : 1;
+
+ a = y / b < z->a ? y / b : z->a;
+ z->c = z->b * bar ((double) a, (double) x);
+ return 0;
+}