aboutsummaryrefslogtreecommitdiff
path: root/gcc/expmed.c
diff options
context:
space:
mode:
authorVlad Lazar <vlad.lazar@arm.com>2018-08-30 09:30:49 +0000
committerVlad Lazar <vladlazar@gcc.gnu.org>2018-08-30 09:30:49 +0000
commitc729951e9c51dabfc3ab7ef864ab2ab8b07b5934 (patch)
tree44fac7fc2c3975388678a1bdef9709ff0111e088 /gcc/expmed.c
parentd0eaed46ce8e5b7c6ebfa0266108cda9cc8fda2e (diff)
downloadgcc-c729951e9c51dabfc3ab7ef864ab2ab8b07b5934.zip
gcc-c729951e9c51dabfc3ab7ef864ab2ab8b07b5934.tar.gz
gcc-c729951e9c51dabfc3ab7ef864ab2ab8b07b5934.tar.bz2
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. From-SVN: r263973
Diffstat (limited to 'gcc/expmed.c')
-rw-r--r--gcc/expmed.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c
index 0922029..caf29e8 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;