aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-12-18 01:13:29 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2007-12-18 01:13:29 +0100
commitdc7c279e97760bba05fa4d637d5652f8559eab3a (patch)
tree8b72d93c5aed08c343fa4fbc730ba4c7f0b0b5bc /gcc
parent44f37984f4e87411999989e2c3ff715a4860d9c3 (diff)
downloadgcc-dc7c279e97760bba05fa4d637d5652f8559eab3a.zip
gcc-dc7c279e97760bba05fa4d637d5652f8559eab3a.tar.gz
gcc-dc7c279e97760bba05fa4d637d5652f8559eab3a.tar.bz2
re PR rtl-optimization/34490 (r128833 causes miscompilation of glibc clock_gettime.c)
PR rtl-optimization/34490 * simplify-rtx.c (simplify_const_relational_operation): If !sign, don't reduce mmin/mmax using num_sign_bit_copies. * gcc.c-torture/execute/20071216-1.c: New test. From-SVN: r131023
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/simplify-rtx.c16
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20071216-1.c38
4 files changed, 58 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c71729d..c3595a4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-12-18 Jakub Jelinek <jakub@redhat.com>
+
+ PR rtl-optimization/34490
+ * simplify-rtx.c (simplify_const_relational_operation): If !sign,
+ don't reduce mmin/mmax using num_sign_bit_copies.
+
2007-12-17 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* doc/install.texi: Change recommended MPFR from 2.2.1 > 2.3.0.
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 0371339..fd14e40 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -4233,15 +4233,17 @@ simplify_const_relational_operation (enum rtx_code code,
else
{
rtx mmin_rtx, mmax_rtx;
- unsigned int sign_copies = num_sign_bit_copies (trueop0, mode);
get_mode_bounds (mode, sign, mode, &mmin_rtx, &mmax_rtx);
- /* Since unsigned mmin will never be interpreted as negative, use
- INTVAL (and an arithmetic right shift). */
- mmin = INTVAL (mmin_rtx) >> (sign_copies - 1);
- /* Since signed mmax will always be positive, use UINTVAL (and
- a logical right shift). */
- mmax = UINTVAL (mmax_rtx) >> (sign_copies - 1);
+ mmin = INTVAL (mmin_rtx);
+ mmax = INTVAL (mmax_rtx);
+ if (sign)
+ {
+ unsigned int sign_copies = num_sign_bit_copies (trueop0, mode);
+
+ mmin >>= (sign_copies - 1);
+ mmax >>= (sign_copies - 1);
+ }
}
switch (code)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1650e37..d42c334 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-12-18 Jakub Jelinek <jakub@redhat.com>
+
+ PR rtl-optimization/34490
+ * gcc.c-torture/execute/20071216-1.c: New test.
+
2007-12-17 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.dg/torture/builtin-math-4.c: Remove XFAIL.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20071216-1.c b/gcc/testsuite/gcc.c-torture/execute/20071216-1.c
new file mode 100644
index 0000000..a337b77
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20071216-1.c
@@ -0,0 +1,38 @@
+/* PR rtl-optimization/34490 */
+
+extern void abort (void);
+
+static int x;
+
+int
+__attribute__((noinline))
+bar (void)
+{
+ return x;
+}
+
+int
+foo (void)
+{
+ long int b = bar ();
+ if ((unsigned long) b < -4095L)
+ return b;
+ if (-b != 38)
+ b = -2;
+ return b + 1;
+}
+
+int
+main (void)
+{
+ x = 26;
+ if (foo () != 26)
+ abort ();
+ x = -39;
+ if (foo () != -1)
+ abort ();
+ x = -38;
+ if (foo () != -37)
+ abort ();
+ return 0;
+}