aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>2017-07-14 18:06:45 +0000
committerWilliam Schmidt <wschmidt@gcc.gnu.org>2017-07-14 18:06:45 +0000
commit3b80566699a6474e82a630652bf85cf872128b6d (patch)
tree523e661ed49cf186942567f2ad03c150f63bea06 /gcc
parentbece580c0ce225b1adeca3afea8d834f7fd83277 (diff)
downloadgcc-3b80566699a6474e82a630652bf85cf872128b6d.zip
gcc-3b80566699a6474e82a630652bf85cf872128b6d.tar.gz
gcc-3b80566699a6474e82a630652bf85cf872128b6d.tar.bz2
re PR tree-optimization/81162 (UBSAN switch triggers incorrect optimization in SLSR)
[gcc] 2016-07-14 Bill Schmidt <wschmidt@linux.vnet.ibm.com> PR tree-optimization/81162 * gimple-ssa-strength-reduction.c (replace_mult_candidate): Don't replace a negate with an add. [gcc/testsuite] 2016-07-14 Bill Schmidt <wschmidt@linux.vnet.ibm.com> PR tree-optimization/81162 * gcc.dg/pr81162.c: New file. From-SVN: r250212
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/gimple-ssa-strength-reduction.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr81162.c17
4 files changed, 31 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3c8effb..fe1d9e9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2016-07-14 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ PR tree-optimization/81162
+ * gimple-ssa-strength-reduction.c (replace_mult_candidate): Don't
+ replace a negate with an add.
+
2017-07-14 James Greenhalgh <james.greenhalgh@arm.com>
* doc/invoke.texi (arm/-mcpu): Document +crypto.
diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index dc2cb46..00c3044 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -2082,13 +2082,14 @@ replace_mult_candidate (slsr_cand_t c, tree basis_name, widest_int bump)
types but allows for safe negation without twisted logic. */
if (wi::fits_shwi_p (bump)
&& bump.to_shwi () != HOST_WIDE_INT_MIN
- /* It is not useful to replace casts, copies, or adds of
+ /* It is not useful to replace casts, copies, negates, or adds of
an SSA name and a constant. */
&& cand_code != SSA_NAME
&& !CONVERT_EXPR_CODE_P (cand_code)
&& cand_code != PLUS_EXPR
&& cand_code != POINTER_PLUS_EXPR
- && cand_code != MINUS_EXPR)
+ && cand_code != MINUS_EXPR
+ && cand_code != NEGATE_EXPR)
{
enum tree_code code = PLUS_EXPR;
tree bump_tree;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index aa4fb1d..073a8e5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-07-14 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ PR tree-optimization/81162
+ * gcc.dg/pr81162.c: New file.
+
2017-07-14 Martin Sebor <msebor@redhat.com>
* gcc.dg/tree-ssa/ssa-dse-30.c: Correct test to look for memmove
diff --git a/gcc/testsuite/gcc.dg/pr81162.c b/gcc/testsuite/gcc.dg/pr81162.c
new file mode 100644
index 0000000..9ce98af
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr81162.c
@@ -0,0 +1,17 @@
+/* PR tree-optimization/81162 */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=undefined -O2" } */
+
+short s;
+int i1 = 1;
+int i2 = 1;
+unsigned char uc = 147;
+
+int main() {
+ s = (-uc + 2147483647) << 0;
+ if (9031239389974324562ULL >= (-((i1 && i2) + uc) ^ -21096) ) {
+ return 0;
+ } else {
+ return -1;
+ }
+}