aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-05-06 07:44:13 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-05-06 07:44:13 +0000
commit2a3f79973f7ff22ab936b3919c31df5c704e1715 (patch)
treede837dd67bb2740f66f8671c13d345e57e9d5e7b /gcc
parentd554bf236e760dec9f9ecf280a8f5523e3ff3aa1 (diff)
downloadgcc-2a3f79973f7ff22ab936b3919c31df5c704e1715.zip
gcc-2a3f79973f7ff22ab936b3919c31df5c704e1715.tar.gz
gcc-2a3f79973f7ff22ab936b3919c31df5c704e1715.tar.bz2
PR 75964: Invalid integer ABS handling in simplify-rtx.c
RTL has no distinction between signed and unsigned values, so it doesn't make sense to test for signed overflow. 2017-05-06 Richard Sandiford <richard.sandiford@linaro.org> gcc/ PR rtl-optimization/75964 * simplify-rtx.c (simplify_const_relational_operation): Remove invalid handling of comparisons of integer ABS. gcc/testsuite/ PR rtl-optimization/75964 * gcc.dg/torture/pr75964.c: New test. From-SVN: r247719
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/simplify-rtx.c28
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr75964.c28
4 files changed, 43 insertions, 24 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index faeac95..58f09a1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-05-06 Richard Sandiford <richard.sandiford@linaro.org>
+
+ PR rtl-optimization/75964
+ * simplify-rtx.c (simplify_const_relational_operation): Remove
+ invalid handling of comparisons of integer ABS.
+
2017-05-06 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.c (ext_80387_constant_init): Do not explicitly
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index ac85a56..7cab26a 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -5316,34 +5316,14 @@ simplify_const_relational_operation (enum rtx_code code,
{
case LT:
/* Optimize abs(x) < 0.0. */
- if (!HONOR_SNANS (mode)
- && (!INTEGRAL_MODE_P (mode)
- || (!flag_wrapv && !flag_trapv)))
- {
- if (INTEGRAL_MODE_P (mode)
- && (issue_strict_overflow_warning
- (WARN_STRICT_OVERFLOW_CONDITIONAL)))
- warning (OPT_Wstrict_overflow,
- ("assuming signed overflow does not occur when "
- "assuming abs (x) < 0 is false"));
- return const0_rtx;
- }
+ if (!INTEGRAL_MODE_P (mode) && !HONOR_SNANS (mode))
+ return const0_rtx;
break;
case GE:
/* Optimize abs(x) >= 0.0. */
- if (!HONOR_NANS (mode)
- && (!INTEGRAL_MODE_P (mode)
- || (!flag_wrapv && !flag_trapv)))
- {
- if (INTEGRAL_MODE_P (mode)
- && (issue_strict_overflow_warning
- (WARN_STRICT_OVERFLOW_CONDITIONAL)))
- warning (OPT_Wstrict_overflow,
- ("assuming signed overflow does not occur when "
- "assuming abs (x) >= 0 is true"));
- return const_true_rtx;
- }
+ if (!INTEGRAL_MODE_P (mode) && !HONOR_NANS (mode))
+ return const_true_rtx;
break;
case UNGE:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fb66adf..587e482 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-05-06 Richard Sandiford <richard.sandiford@linaro.org>
+
+ PR rtl-optimization/75964
+ * gcc.dg/torture/pr75964.c: New test.
+
2017-05-06 Tom de Vries <tom@codesourcery.com>
PR testsuite/80606
diff --git a/gcc/testsuite/gcc.dg/torture/pr75964.c b/gcc/testsuite/gcc.dg/torture/pr75964.c
new file mode 100644
index 0000000..3b895ba
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr75964.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+
+typedef __UINT8_TYPE__ uint8_t;
+
+uint8_t __attribute__ ((noinline, noclone))
+abs8 (uint8_t x)
+{
+ if (x & 0x80)
+ x = -x;
+
+ if (x & 0x80)
+ x = 0x7f;
+
+ return x;
+}
+
+int
+main (void)
+{
+ if (abs8 (0) != 0
+ || abs8 (1) != 1
+ || abs8 (127) != 127
+ || abs8 (128) != 127
+ || abs8 (129) != 127
+ || abs8 (255) != 1)
+ __builtin_abort ();
+ return 0;
+}