Commit 534bd33b by Marc Glisse Committed by Marc Glisse

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
parent c3dc5e66
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.
2015-05-26 Richard Sandiford <richard.sandiford@arm.com> 2015-05-26 Richard Sandiford <richard.sandiford@arm.com>
* caller-save.c (init_caller_save): Base temporary register numbers * caller-save.c (init_caller_save): Base temporary register numbers
......
...@@ -9183,24 +9183,11 @@ fold_comparison (location_t loc, enum tree_code code, tree type, ...@@ -9183,24 +9183,11 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
fold_convert_loc (loc, newtype, targ0), fold_convert_loc (loc, newtype, targ0),
fold_convert_loc (loc, newtype, targ1)); fold_convert_loc (loc, newtype, targ1));
/* (-a) CMP (-b) -> b CMP a */
if (TREE_CODE (arg0) == NEGATE_EXPR
&& TREE_CODE (arg1) == NEGATE_EXPR)
return fold_build2_loc (loc, code, type, TREE_OPERAND (arg1, 0),
TREE_OPERAND (arg0, 0));
if (TREE_CODE (arg1) == REAL_CST) if (TREE_CODE (arg1) == REAL_CST)
{ {
REAL_VALUE_TYPE cst; REAL_VALUE_TYPE cst;
cst = TREE_REAL_CST (arg1); cst = TREE_REAL_CST (arg1);
/* (-a) CMP CST -> a swap(CMP) (-CST) */
if (TREE_CODE (arg0) == NEGATE_EXPR)
return fold_build2_loc (loc, swap_tree_comparison (code), type,
TREE_OPERAND (arg0, 0),
build_real (TREE_TYPE (arg1),
real_value_negate (&cst)));
/* IEEE doesn't distinguish +0 and -0 in comparisons. */ /* IEEE doesn't distinguish +0 and -0 in comparisons. */
/* a CMP (-0) -> a CMP 0 */ /* a CMP (-0) -> a CMP 0 */
if (REAL_VALUE_MINUS_ZERO (cst)) if (REAL_VALUE_MINUS_ZERO (cst))
......
...@@ -38,6 +38,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -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) ge gt ne eq lt le ordered unordered ge gt le lt ltgt uneq)
(define_operator_list inverted_tcc_comparison_with_nans (define_operator_list inverted_tcc_comparison_with_nans
unge ungt ne eq unlt unle ordered unordered ge gt le lt ltgt uneq) 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 /* Simplifications of operations with one constant operand and
...@@ -980,6 +982,24 @@ along with GCC; see the file COPYING3. If not see ...@@ -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)) (bit_and:c (ordered @0 @0) (ordered:c@2 @0 @1))
@2) @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. */ /* Simplification of math builtins. */
(define_operator_list LOG BUILT_IN_LOGF BUILT_IN_LOG BUILT_IN_LOGL) (define_operator_list LOG BUILT_IN_LOGF BUILT_IN_LOG BUILT_IN_LOGL)
......
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