diff options
author | Patrick Palka <ppalka@gcc.gnu.org> | 2016-08-12 16:07:40 +0000 |
---|---|---|
committer | Patrick Palka <ppalka@gcc.gnu.org> | 2016-08-12 16:07:40 +0000 |
commit | 7fd82d528e715fabf3688346250d47c20f149665 (patch) | |
tree | c1db4a73282537a4a6550488a4eab0f1005536cc | |
parent | 2f1364c2b325eec008bf461a0d77264618a9afe8 (diff) | |
download | gcc-7fd82d528e715fabf3688346250d47c20f149665.zip gcc-7fd82d528e715fabf3688346250d47c20f149665.tar.gz gcc-7fd82d528e715fabf3688346250d47c20f149665.tar.bz2 |
Fix PR middle-end/71654 (missed shortening of a compare)
gcc/ChangeLog:
PR middle-end/71654
* match.pd ((T)A CMP (T)B -> A CMP B): Allow (T)A to be a
sign-changing cast from a shorter unsigned type to a wider
signed type.
gcc/testsuite/ChangeLog:
PR middle-end/71654
* gcc.dg/c-c++-common/pr71654.c: New test.
* gcc.dg/tree-ssa/vrp23: Add -fno-tree-forwprop to
dg-options.
* gcc.dg/tree-ssa/vrp24: Likewise.
From-SVN: r239421
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/match.pd | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/pr71654.c | 28 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/vrp23.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/vrp24.c | 2 |
6 files changed, 48 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6a4f4bf..7a1d691 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-08-12 Patrick Palka <ppalka@gcc.gnu.org> + + PR middle-end/71654 + * match.pd ((T)A CMP (T)B -> A CMP B): Allow (T)A to be a + sign-changing cast from a shorter unsigned type to a wider + signed type. + 2016-08-12 Jakub Jelinek <jakub@redhat.com> * config/i386/sse.md (avx512dq_vextract<shuffletype>64x2_1_maskm, diff --git a/gcc/match.pd b/gcc/match.pd index ac7cfff..da87b02 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -2350,7 +2350,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (TYPE_PRECISION (TREE_TYPE (@0)) > TYPE_PRECISION (TREE_TYPE (@00))) /* If possible, express the comparison in the shorter mode. */ (if ((cmp == EQ_EXPR || cmp == NE_EXPR - || TYPE_UNSIGNED (TREE_TYPE (@0)) == TYPE_UNSIGNED (TREE_TYPE (@00))) + || TYPE_UNSIGNED (TREE_TYPE (@0)) == TYPE_UNSIGNED (TREE_TYPE (@00)) + || (!TYPE_UNSIGNED (TREE_TYPE (@0)) + && TYPE_UNSIGNED (TREE_TYPE (@00)))) && (types_match (TREE_TYPE (@10), TREE_TYPE (@00)) || ((TYPE_PRECISION (TREE_TYPE (@00)) >= TYPE_PRECISION (TREE_TYPE (@10))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8040f34..89071d2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2016-08-12 Patrick Palka <ppalka@gcc.gnu.org> + + PR middle-end/71654 + * gcc.dg/c-c++-common/pr71654.c: New test. + * gcc.dg/tree-ssa/vrp23: Add -fno-tree-forwprop to + dg-options. + * gcc.dg/tree-ssa/vrp24: Likewise. + 2016-08-12 Jakub Jelinek <jakub@redhat.com> PR c/67410 diff --git a/gcc/testsuite/c-c++-common/pr71654.c b/gcc/testsuite/c-c++-common/pr71654.c new file mode 100644 index 0000000..2942493 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr71654.c @@ -0,0 +1,28 @@ +/* PR middle-end/71654 */ +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +unsigned char i0, i1; + +void foo (void); + +int +main (void) +{ + int j = i0; + if (j < 4) + { + if (i0 & 4) + foo (); + } + + unsigned int k = i1; + if (k < 8) + { + if (i1 & 8) + foo (); + } + + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp23.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp23.c index b877ccc..ae68c090 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp23.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp23.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1-details" } */ +/* { dg-options "-O2 -fno-tree-forwprop -fdump-tree-vrp1-details" } */ void aa (void); void aos (void); diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c index e740575..853ee21 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1-details" } */ +/* { dg-options "-O2 -fno-tree-forwprop -fdump-tree-vrp1-details" } */ struct rtx_def; |