diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2015-05-26 13:14:16 +0200 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2015-05-26 11:14:16 +0000 |
commit | 534bd33b61d08e0bf4d58efbeb3da5a368f8a247 (patch) | |
tree | d7b381032a45d7b3441c2f5139e9c9af5a65d583 /gcc/match.pd | |
parent | c3dc5e6654a2911c955eb9371ed7d6e5c2d1a174 (diff) | |
download | gcc-534bd33b61d08e0bf4d58efbeb3da5a368f8a247.tar.gz |
match.pd (swapped_tcc_comparison): New operator list.
2015-05-26 Marc Glisse <marc.glisse@inria.fr>
* match.pd (swapped_tcc_comparison): New operator list.
(-A CMP -B): New simplification.
* fold-const.c (fold_comparison): Remove corresponding code.
From-SVN: r223689
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 3ac36455278..1e46677d525 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -38,6 +38,8 @@ along with GCC; see the file COPYING3. If not see ge gt ne eq lt le ordered unordered ge gt le lt ltgt uneq) (define_operator_list inverted_tcc_comparison_with_nans unge ungt ne eq unlt unle ordered unordered ge gt le lt ltgt uneq) +(define_operator_list swapped_tcc_comparison + gt ge eq ne le lt unordered ordered ungt unge unlt unle uneq ltgt) /* Simplifications of operations with one constant operand and @@ -980,6 +982,24 @@ along with GCC; see the file COPYING3. If not see (bit_and:c (ordered @0 @0) (ordered:c@2 @0 @1)) @2) +/* -A CMP -B -> B CMP A. */ +(for cmp (tcc_comparison) + scmp (swapped_tcc_comparison) + (simplify + (cmp (negate @0) (negate @1)) + (if (FLOAT_TYPE_P (TREE_TYPE (@0)) + || (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0)) + && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)))) + (scmp @0 @1))) + (simplify + (cmp (negate @0) CONSTANT_CLASS_P@1) + (if (FLOAT_TYPE_P (TREE_TYPE (@0)) + || (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0)) + && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)))) + (with { tree tem = fold_unary (NEGATE_EXPR, TREE_TYPE (@0), @1); } + (if (tem && !TREE_OVERFLOW (tem)) + (scmp @0 { tem; })))))) + /* Simplification of math builtins. */ (define_operator_list LOG BUILT_IN_LOGF BUILT_IN_LOG BUILT_IN_LOGL) |