Commit 66cc6273 by Marek Polacek Committed by Marek Polacek

match.pd ((x | y) & ~(x & y) -> x ^ y, (x | y) & (~x ^ y) -> x & y): New patterns.

	* match.pd ((x | y) & ~(x & y) -> x ^ y,
	(x | y) & (~x ^ y) -> x & y): New patterns.

	* gcc.dg/fold-and-1.c: New test.
	* gcc.dg/fold-and-2.c: New test.

From-SVN: r225001
parent 9d8895c9
2015-06-26 Marek Polacek <polacek@redhat.com>
* match.pd ((x | y) & ~(x & y) -> x ^ y,
(x | y) & (~x ^ y) -> x & y): New patterns.
2015-06-26 Richard Sandiford <richard.sandiford@arm.com> 2015-06-26 Richard Sandiford <richard.sandiford@arm.com>
* rtl.h (emit): Add an optional boolean parameter to control * rtl.h (emit): Add an optional boolean parameter to control
......
...@@ -367,6 +367,16 @@ along with GCC; see the file COPYING3. If not see ...@@ -367,6 +367,16 @@ along with GCC; see the file COPYING3. If not see
(minus (bit_ior @0 @1) (bit_and @0 @1)) (minus (bit_ior @0 @1) (bit_and @0 @1))
(bit_xor @0 @1)) (bit_xor @0 @1))
/* (x | y) & ~(x & y) -> x ^ y */
(simplify
(bit_and:c (bit_ior @0 @1) (bit_not (bit_and @0 @1)))
(bit_xor @0 @1))
/* (x | y) & (~x ^ y) -> x & y */
(simplify
(bit_and:c (bit_ior:c @0 @1) (bit_xor:c @1 (bit_not @0)))
(bit_and @0 @1))
(simplify (simplify
(abs (negate @0)) (abs (negate @0))
(abs @0)) (abs @0))
......
2015-06-26 Marek Polacek <polacek@redhat.com>
* gcc.dg/fold-and-1.c: New test.
* gcc.dg/fold-and-2.c: New test.
2015-06-26 Eric Botcazou <ebotcazou@adacore.com> 2015-06-26 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/warn11.adb: Add missing dg directive. * gnat.dg/warn11.adb: Add missing dg directive.
......
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-cddce1" } */
int
fn1 (int x, int y)
{
int tem1 = x | y;
int tem2 = ~(x & y);
return tem1 & tem2;
}
int
fn2 (int x, int y)
{
int tem1 = y | x;
int tem2 = ~(x & y);
return tem1 & tem2;
}
int
fn3 (int x, int y)
{
int tem1 = x | y;
int tem2 = ~(y & x);
return tem1 & tem2;
}
int
fn4 (int x, int y)
{
int tem1 = y | x;
int tem2 = ~(y & x);
return tem1 & tem2;
}
int
fn5 (int x, int y)
{
int tem1 = ~(x & y);
int tem2 = x | y;
return tem1 & tem2;
}
int
fn6 (int x, int y)
{
int tem1 = ~(x & y);
int tem2 = y | x;
return tem1 & tem2;
}
int
fn7 (int x, int y)
{
int tem1 = ~(y & x);
int tem2 = x | y;
return tem1 & tem2;
}
int
fn8 (int x, int y)
{
int tem1 = ~(y & x);
int tem2 = y | x;
return tem1 & tem2;
}
/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */
/* { dg-final { scan-tree-dump-not " \\& " "cddce1" } } */
/* { dg-final { scan-tree-dump-not "~" "cddce1" } } */
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-cddce1" } */
int
fn1 (int x, int y)
{
int tem1 = x | y;
int tem2 = ~x ^ y;
return tem1 & tem2;
}
int
fn2 (int x, int y)
{
int tem1 = y | x;
int tem2 = ~x ^ y;
return tem1 & tem2;
}
int
fn3 (int x, int y)
{
int tem1 = x | y;
int tem2 = y ^ ~x;
return tem1 & tem2;
}
int
fn4 (int x, int y)
{
int tem1 = y | x;
int tem2 = y ^ ~x;
return tem1 & tem2;
}
int
fn5 (int x, int y)
{
int tem1 = ~x ^ y;
int tem2 = x | y;
return tem1 & tem2;
}
int
fn6 (int x, int y)
{
int tem1 = ~x ^ y;
int tem2 = y | x;
return tem1 & tem2;
}
int
fn7 (int x, int y)
{
int tem1 = y ^ ~x;
int tem2 = x | y;
return tem1 & tem2;
}
int
fn8 (int x, int y)
{
int tem1 = y ^ ~x;
int tem2 = y | x;
return tem1 & tem2;
}
/* { dg-final { scan-tree-dump-not " \\| " "cddce1" } } */
/* { dg-final { scan-tree-dump-not " \\^ " "cddce1" } } */
/* { dg-final { scan-tree-dump-not "~" "cddce1" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment