diff options
author | mpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-06-30 16:36:44 +0000 |
---|---|---|
committer | mpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-06-30 16:36:44 +0000 |
commit | 754e0869048f4c058982b3b75300fb0eb555b79d (patch) | |
tree | 5b8dce2e677b5633bbb88ff76efadcddc0decb73 | |
parent | 48bd2bec89d68195aec2cc3d1dc480b2192b8f69 (diff) | |
download | gcc-754e0869048f4c058982b3b75300fb0eb555b79d.tar.gz |
* 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.
* 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
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/match.pd | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/fold-ior-3.c | 35 |
4 files changed, 42 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3dabe907a44..92953b2f3f2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 <rguenther@suse.de> * fold-const.c (fold_binary_loc): Move ~x & ~y -> ~(x | y) and diff --git a/gcc/match.pd b/gcc/match.pd index e6728f47096..74e42efd807 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 95a75e569ea..7b51e77b7f8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 <3dw4rd@verizon.net> Implement N4197 - Adding u8 character literals diff --git a/gcc/testsuite/gcc.dg/fold-ior-3.c b/gcc/testsuite/gcc.dg/fold-ior-3.c new file mode 100644 index 00000000000..ed89ff9188c --- /dev/null +++ b/gcc/testsuite/gcc.dg/fold-ior-3.c @@ -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" } } */ |