diff options
author | Richard Biener <rguenther@suse.de> | 2016-11-23 11:33:03 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-11-23 11:33:03 +0000 |
commit | 0eb078fe20d443e2981a7b69067547e7ab80565c (patch) | |
tree | a629c915e64cc49bb9a5f59a7fbcef57017d423a | |
parent | efb71232412323c504f3af95ed6679abfd15cb7a (diff) | |
download | gcc-0eb078fe20d443e2981a7b69067547e7ab80565c.zip gcc-0eb078fe20d443e2981a7b69067547e7ab80565c.tar.gz gcc-0eb078fe20d443e2981a7b69067547e7ab80565c.tar.bz2 |
re PR middle-end/71762 (~X & Y to X < Y doesn't work for uninitialized values)
2016-11-23 Richard Biener <rguenther@suse.de>
PR middle-end/71762
* match.pd ((~X & Y) -> X < Y, (X & ~Y) -> Y < X,
(~X | Y) -> X <= Y, (X | ~Y) -> Y <= X): Remove.
* gcc.dg/torture/pr71762-1.c: New testcase.
* gcc.dg/torture/pr71762-2.c: Likewise.
* gcc.dg/torture/pr71762-3.c: Likewise.
* gcc.dg/tree-ssa/forwprop-28.c: XFAIL.
From-SVN: r242747
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/match.pd | 27 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr71762-1.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr71762-2.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr71762-3.c | 22 |
6 files changed, 71 insertions, 27 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c0c529f..192d6e4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2016-11-23 Richard Biener <rguenther@suse.de> + PR middle-end/71762 + * match.pd ((~X & Y) -> X < Y, (X & ~Y) -> Y < X, + (~X | Y) -> X <= Y, (X | ~Y) -> Y <= X): Remove. + +2016-11-23 Richard Biener <rguenther@suse.de> + PR lto/78472 * tree.c (gimple_canonical_types_compatible_p): Ignore zero-sized fields. diff --git a/gcc/match.pd b/gcc/match.pd index 3fece35..6665412 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -963,33 +963,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (op:c truth_valued_p@0 (logical_inverted_value @0)) { constant_boolean_node (op == NE_EXPR ? true : false, type); })) -/* If arg1 and arg2 are booleans (or any single bit type) - then try to simplify: - - (~X & Y) -> X < Y - (X & ~Y) -> Y < X - (~X | Y) -> X <= Y - (X | ~Y) -> Y <= X - - But only do this if our result feeds into a comparison as - this transformation is not always a win, particularly on - targets with and-not instructions. - -> simplify_bitwise_binary_boolean */ -(simplify - (ne (bit_and:c (bit_not @0) @1) integer_zerop) - (if (INTEGRAL_TYPE_P (TREE_TYPE (@1)) - && TYPE_PRECISION (TREE_TYPE (@1)) == 1) - (if (TYPE_UNSIGNED (TREE_TYPE (@1))) - (lt @0 @1) - (gt @0 @1)))) -(simplify - (ne (bit_ior:c (bit_not @0) @1) integer_zerop) - (if (INTEGRAL_TYPE_P (TREE_TYPE (@1)) - && TYPE_PRECISION (TREE_TYPE (@1)) == 1) - (if (TYPE_UNSIGNED (TREE_TYPE (@1))) - (le @0 @1) - (ge @0 @1)))) - /* ~~x -> x */ (simplify (bit_not (bit_not @0)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f4306f0..64fbed7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,13 @@ 2016-11-23 Richard Biener <rguenther@suse.de> + PR middle-end/71762 + * gcc.dg/torture/pr71762-1.c: New testcase. + * gcc.dg/torture/pr71762-2.c: Likewise. + * gcc.dg/torture/pr71762-3.c: Likewise. + * gcc.dg/tree-ssa/forwprop-28.c: XFAIL. + +2016-11-23 Richard Biener <rguenther@suse.de> + PR lto/78472 * g++.dg/lto/pr78472_0.c: New testcase. * g++.dg/lto/pr78472_1.C: Likewise. diff --git a/gcc/testsuite/gcc.dg/torture/pr71762-1.c b/gcc/testsuite/gcc.dg/torture/pr71762-1.c new file mode 100644 index 0000000..d20cbc3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr71762-1.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-additional-options "-fdisable-rtl-init-regs" } */ + +static _Bool +foo (_Bool a, _Bool b) +{ + int x = a && ! b; + return x != 0; +} + +int y = 1; +int main() +{ + _Bool x; + if (foo (x, y)) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr71762-2.c b/gcc/testsuite/gcc.dg/torture/pr71762-2.c new file mode 100644 index 0000000..65047cb --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr71762-2.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ + +static _Bool +foo (_Bool a, _Bool b) +{ + int x = a && ! b; + return x != 0; +} + +int y = 1; +int main() +{ + _Bool x[32]; + if (foo (x[1], y)) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr71762-3.c b/gcc/testsuite/gcc.dg/torture/pr71762-3.c new file mode 100644 index 0000000..4fd5f98 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr71762-3.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ + +static _Bool +foo (_Bool a, _Bool b) +{ + int x = a && ! b; + return x != 0; +} + +int y = 1; +int main() +{ + register _Bool x + /* Add register spec for the argv parameter to main. */ +#if __i386__ || __x86_64__ + __asm__("%esi") +#endif + ; + if (foo (x, y)) + __builtin_abort (); + return 0; +} |