diff options
author | pinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-02-23 17:58:48 +0000 |
---|---|---|
committer | pinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-02-23 17:58:48 +0000 |
commit | 3d72a1b5ff364096199c1f9ebce2bb4fde8dfab7 (patch) | |
tree | ee2a5464a8fd46288917b5f1ea33c72955e8af86 | |
parent | c12ee0c6f87eba261d98bca334f8ea8026d0dd7c (diff) | |
download | gcc-3d72a1b5ff364096199c1f9ebce2bb4fde8dfab7.tar.gz |
2008-02-23 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR rtl-opt/33512
* simplify-rtx.c (simplify_binary_operation_1): Add simplification
of (and X (ior (not X) Y) and (and (ior (not X) Y) X).
2008-02-23 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR rtl-opt/33512
* gcc.dg/and-1.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132575 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/and-1.c | 10 |
4 files changed, 34 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 235208cc4f3..9bf9a9d915a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2008-02-23 Andrew Pinski <andrew_pinski@playstation.sony.com> + PR rtl-opt/33512 + * simplify-rtx.c (simplify_binary_operation_1): Add simplification + of (and X (ior (not X) Y) and (and (ior (not X) Y) X). + +2008-02-23 Andrew Pinski <andrew_pinski@playstation.sony.com> + PR pch/35027 * c-pch.c (c_common_valid_pch): Make the "too short to be a PCH file" warning condtional on -Winvalid-PCH. diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index f8756040ce0..03fbc750dcf 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2428,6 +2428,19 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode, return simplify_gen_binary (code, mode, tem, op1); } } + + /* (and X (ior (not X) Y) -> (and X Y) */ + if (GET_CODE (op1) == IOR + && GET_CODE (XEXP (op1, 0)) == NOT + && op0 == XEXP (XEXP (op1, 0), 0)) + return simplify_gen_binary (AND, mode, op0, XEXP (op1, 1)); + + /* (and (ior (not X) Y) X) -> (and X Y) */ + if (GET_CODE (op0) == IOR + && GET_CODE (XEXP (op0, 0)) == NOT + && op1 == XEXP (XEXP (op0, 0), 0)) + return simplify_gen_binary (AND, mode, op1, XEXP (op0, 1)); + tem = simplify_associative_operation (code, mode, op0, op1); if (tem) return tem; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b111ef4da71..e53852be3e6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-02-23 Andrew Pinski <andrew_pinski@playstation.sony.com> + + PR rtl-opt/33512 + * gcc.dg/and-1.c: New test. + 2008-02-23 Daniel Jacobowitz <dan@codesourcery.com> * gcc.c-torture/execute/20080222-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/and-1.c b/gcc/testsuite/gcc.dg/and-1.c new file mode 100644 index 00000000000..c66e4e15fac --- /dev/null +++ b/gcc/testsuite/gcc.dg/and-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler "and" { target powerpc*-*-* spu-*-* } } } */ +/* There should be no nand for this testcase (for either PPC or SPU). */ +/* { dg-final { scan-assembler-not "nand" { target powerpc*-*-* spu-*-* } } } */ + +int f(int y) +{ + return y & ~(y & -y); +} |