aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlad Lazar <vlad.lazar@arm.com>2018-08-30 09:30:49 +0000
committerVlad Lazar <vlad.lazar@arm.com>2018-08-30 09:30:49 +0000
commit6db35d64f20359fd37513252e740ba018d7f669d (patch)
tree44fac7fc2c3975388678a1bdef9709ff0111e088
parent9069287a8d82c07c61e9922151cc65f204412e6f (diff)
Enable underflow check in canonicalize_comparison. (PR86995)
gcc/ 2018-08-30 Vlad Lazar <vlad.lazar@arm.com> PR middle-end/86995 * expmed.c (canonicalize_comparison): Use wi::sub instead of wi::add if to_add is negative. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@263973 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/expmed.c8
2 files changed, 13 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8865f31a43c..e57a5921559 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2018-08-30 Vlad Lazar <vlad.lazar@arm.com>
+
+ PR middle-end/86995
+ * expmed.c (canonicalize_comparison): Use wi::sub instead of wi::add
+ if to_add is negative.
+
2018-08-29 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR middle-end/87053
diff --git a/gcc/expmed.c b/gcc/expmed.c
index 0922029de80..caf29e88924 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -6239,7 +6239,13 @@ canonicalize_comparison (machine_mode mode, enum rtx_code *code, rtx *imm)
wrapping around in the case of unsigned values. If any occur
cancel the optimization. */
wi::overflow_type overflow = wi::OVF_NONE;
- wide_int imm_modif = wi::add (imm_val, to_add, sgn, &overflow);
+ wide_int imm_modif;
+
+ if (to_add == 1)
+ imm_modif = wi::add (imm_val, 1, sgn, &overflow);
+ else
+ imm_modif = wi::sub (imm_val, 1, sgn, &overflow);
+
if (overflow)
return;