On Wed, 20 Aug 2014, Richard Biener wrote:

Committed.

Also makes visible a desirable change I plan for if-exprs.  They
should behave like outer ifs and allow us to write that series
of pattern as

(for op in eq ne
 /* Simplify X * C1 CMP 0 to X CMP 0 if C1 is not zero.  */
 (simplify
   (op (mult @0 INTEGER_CST@1) integer_zerop@2)
   /* In fold-const.c we have this and the following patterns
      combined because there we can "compute" the operator
      to use by using swap_tree_comparison.  */
   (if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)))
     (if (tree_int_cst_sgn (@1) > 0)
         (op @0 @2))
     (if (tree_int_cst_sgn (@1) < 0 && op == EQ_EXPR)
         (ne @0 @2))
     (if (tree_int_cst_sgn (@1) < 0 && op == NE_EXPR)
         (eq @0 @2)))))

that is, inner ifs have two operands, one condition and one
"result" (which can be another if).  And the simplify
now has one mandatory match operand and at least one
result operand (if which all but the last have to be an
'if').

Not related to how you do "if" and such, but this simplification doesn't make sense. swap_tree_comparison preserves eq and ne, you only care that @1 is non-zero. It is for comparisons like lt that the sign can change the operation.

--
Marc Glisse

Reply via email to