diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-10-04 10:50:19 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-10-04 10:50:19 +0000 |
commit | f95810b50bab4e1397e51b12aa8e73cbf6046a47 (patch) | |
tree | b7c37bc4d6cbafc2c9e402dc66394ed26dd746e3 /gcc | |
parent | 707905d0773e5a8eebb9ba65164f43dc08c658b1 (diff) | |
download | gcc-f95810b50bab4e1397e51b12aa8e73cbf6046a47.zip gcc-f95810b50bab4e1397e51b12aa8e73cbf6046a47.tar.gz gcc-f95810b50bab4e1397e51b12aa8e73cbf6046a47.tar.bz2 |
PR82413: Mismatched precisions in build_range_check
build_range_check explicitly allows LOW and HIGH to be a different type
from EXP, so we need to use w::to_widest when comparing a value based on
HIGH with a value based on EXP's type.
2017-10-04 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
PR tree-optimization/82413
* fold-const.c (build_range_check): Use widest_int when comparing
the maximum ETYPE value with HIGH.
gcc/testsuite/
PR tree-optimization/82413
* g++.dg/pr82413.C: New test.
From-SVN: r253401
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fold-const.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/pr82413.C | 3 |
4 files changed, 15 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a4fd9d8..76c1f1b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-10-04 Richard Sandiford <richard.sandiford@linaro.org> + + PR tree-optimization/82413 + * fold-const.c (build_range_check): Use widest_int when comparing + the maximum ETYPE value with HIGH. + 2017-10-04 Wilco Dijkstra <wdijkstr@arm.com> PR rtl-optimization/82396 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index fa9d1bb..ae037ce 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -4851,7 +4851,7 @@ build_range_check (location_t loc, tree type, tree exp, int in_p, { int prec = TYPE_PRECISION (etype); - if (wi::mask (prec - 1, false, prec) == high) + if (wi::mask <widest_int> (prec - 1, false) == wi::to_widest (high)) { if (TYPE_UNSIGNED (etype)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 883392f..2c96f3a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-04 Richard Sandiford <richard.sandiford@linaro.org> + + PR tree-optimization/82413 + * g++.dg/pr82413.C: New test. + 2017-10-04 Paul Thomas <pault@gcc.gnu.org> PR fortran/77296 diff --git a/gcc/testsuite/g++.dg/pr82413.C b/gcc/testsuite/g++.dg/pr82413.C new file mode 100644 index 0000000..a44751d --- /dev/null +++ b/gcc/testsuite/g++.dg/pr82413.C @@ -0,0 +1,3 @@ +bool a; +int b; +void c() { b &&a <= 0; } |