diff options
author | Richard Sandiford <rdsandiford@googlemail.com> | 2013-01-02 11:43:22 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2013-01-02 11:43:22 +0000 |
commit | 635b0b0cfcbad6c9807d58307d316072f1303011 (patch) | |
tree | eaf13caf18386a72a6812debdbf74552de5aaa98 | |
parent | 4ff4293f15f3a442f6552e764d2127640932b253 (diff) | |
download | gcc-635b0b0cfcbad6c9807d58307d316072f1303011.zip gcc-635b0b0cfcbad6c9807d58307d316072f1303011.tar.gz gcc-635b0b0cfcbad6c9807d58307d316072f1303011.tar.bz2 |
tree-vrp.c (range_fits_type_p): Require the MSB of the double_int to be clear for sign changes.
gcc/
* tree-vrp.c (range_fits_type_p): Require the MSB of the double_int
to be clear for sign changes.
gcc/testsuite/
* gcc.dg/torture/fp-int-convert-2.c: New test.
From-SVN: r194800
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/fp-int-convert-2.c | 18 | ||||
-rw-r--r-- | gcc/tree-vrp.c | 8 |
4 files changed, 32 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f7b15c3..f686cf6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2013-01-02 Richard Sandiford <rdsandiford@googlemail.com> + + * tree-vrp.c (range_fits_type_p): Require the MSB of the double_int + to be clear for sign changes. + 2013-01-01 Jan Hubicka <jh@suse.cz> * ipa-inline-analysis.c: Fix formatting. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 147b1c7..faa12fd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2013-01-02 Richard Sandiford <rdsandiford@googlemail.com> + + * gcc.dg/torture/fp-int-convert-2.c: New test. + 2013-01-01 Jerry DeLisle <jvdelisle@gcc.gnu.org> * gfortran.dg/newunit_3.f90: Add dg-do run. diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-2.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-2.c new file mode 100644 index 0000000..4c00e8f --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-2.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int128 } */ + +extern void abort (void); + +float __attribute__((noinline)) +f (__uint128_t x) +{ + return x + 1; +} + +int +main (void) +{ + if (f (0xffffffffu) == 0) + abort (); + return 0; +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 4319c60..6b8cbf3 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -8766,9 +8766,11 @@ range_fits_type_p (value_range_t *vr, unsigned precision, bool unsigned_p) || TREE_CODE (vr->max) != INTEGER_CST) return false; - /* For precision-preserving sign-changes the MSB of the double-int - has to be clear. */ - if (src_precision == precision + /* For sign changes, the MSB of the double_int has to be clear. + An unsigned value with its MSB set cannot be represented by + a signed double_int, while a negative value cannot be represented + by an unsigned double_int. */ + if (TYPE_UNSIGNED (src_type) != unsigned_p && (TREE_INT_CST_HIGH (vr->min) | TREE_INT_CST_HIGH (vr->max)) < 0) return false; |