From: Patrick Palka Date: Fri, 12 Aug 2016 16:07:40 +0000 (+0000) Subject: Fix PR middle-end/71654 (missed shortening of a compare) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7fd82d528e715fabf3688346250d47c20f149665;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6a4f4bf194c..7a1d691d972 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-08-12 Patrick Palka + + 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 * config/i386/sse.md (avx512dq_vextract64x2_1_maskm, diff --git a/gcc/match.pd b/gcc/match.pd index ac7cfff0ae2..da87b027b62 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 8040f34e775..89071d2882f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2016-08-12 Patrick Palka + + 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 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 00000000000..2942493af67 --- /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 b877ccc607b..ae68c090f77 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 e7405750f41..853ee21bb8f 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;