Skip to content

Commit

Permalink
* match.pd (~x | x): Don't use tree_nop_conversion_p. Build
Browse files Browse the repository at this point in the history
	the final expression with the operand's type and then convert
	it to the type of the expression.

	* gcc.dg/fold-ior-3.c: New test.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225196 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
mpolacek committed Jun 30, 2015
1 parent 48bd2be commit 754e086
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
4 changes: 4 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
* match.pd (X - (X / Y) * Y): Use convert1 and convert2. Convert
both operands of the resulting expression.

* match.pd (~x | x): Don't use tree_nop_conversion_p. Build
the final expression with the operand's type and then convert
it to the type of the expression.

2015-06-30 Richard Biener <[email protected]>

* fold-const.c (fold_binary_loc): Move ~x & ~y -> ~(x | y) and
Expand Down
3 changes: 1 addition & 2 deletions gcc/match.pd
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,7 @@ along with GCC; see the file COPYING3. If not see
/* ~x | x -> -1 */
(simplify
(bit_ior:c (convert? @0) (convert? (bit_not @0)))
(if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
{ build_all_ones_cst (type); }))
(convert { build_all_ones_cst (TREE_TYPE (@0)); }))

/* x ^ x -> 0 */
(simplify
Expand Down
2 changes: 2 additions & 0 deletions gcc/testsuite/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* gcc.dg/fold-minus-6.c: New test.

* gcc.dg/fold-ior-3.c: New test.

2015-06-30 Edward Smith-Rowland <[email protected]>

Implement N4197 - Adding u8 character literals
Expand Down
35 changes: 35 additions & 0 deletions gcc/testsuite/gcc.dg/fold-ior-3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-cddce1" } */

int
fn1 (_Bool a)
{
return ((int) a) | ((int) ~a);
}

int
fn2 (unsigned char a)
{
return ((int) a) | ((int) ~a);
}

int
fn3 (unsigned short a)
{
return ((int) a) | ((int) ~a);
}

int
fn4 (signed char a)
{
return ((int) a) | ((int) ~a);
}

int
fn5 (signed short a)
{
return ((int) a) | ((int) ~a);
}

/* { dg-final { scan-tree-dump-not "~" "cddce1" } } */
/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */

0 comments on commit 754e086

Please sign in to comment.