[go: up one dir, main page]

Skip to content

Commit

Permalink
Fix PR middle-end/71654 (missed shortening of a compare)
Browse files Browse the repository at this point in the history
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.



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239421 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
ppalka committed Aug 12, 2016
1 parent 7175bb2 commit 7079d57
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
7 changes: 7 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 3 additions & 1 deletion gcc/match.pd
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
8 changes: 8 additions & 0 deletions gcc/testsuite/ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
28 changes: 28 additions & 0 deletions gcc/testsuite/c-c++-common/pr71654.c
Original file line number Diff line number Diff line change
@@ -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;
}

2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.dg/tree-ssa/vrp23.c
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.dg/tree-ssa/vrp24.c
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 7079d57

Please sign in to comment.