On Tue, Aug 19, 2014 at 11:08:39AM +0200, Manuel López-Ibáñez wrote:
> > Not sure about that: it matters whether the CST is a LHS or a RHS
> > - because we want to say if the comparison is always true or false.
> > I tried to introduce some bool flag, but that didn't really help
> > readability IMHO.  (The tree_int_cst_sgn is compared to 1 and -1, or
> > to -1 and 1.)
> 
> Oh, yes. I missed that. Sorry. What about?
> 
> tree op = (TREE_CODE (op0) == INTEGER_CST) ? op0
>            : (TREE_CODE (op1) == INTEGER_CST) ? op1 : NULL_TREE;
> 
> if (op == NULL_TREE)
> return;
> 
> if (!integer_zerop (op) && !integer_onep(op))
> {
>       int sign = (TREE_CODE (op0) == INTEGER_CST)
>                  ? tree_int_cst_sgn (op) : -tree_int_cst_sgn (op);
>       if (code == EQ_EXPR
>          || ((code == GT_EXPR || code == GE_EXPR)
>              && sign < 0)
>          || ((code == LT_EXPR || code == LE_EXPR)
>              && sign > 0))
> 
> or some variation of the above could work, no?

Ok, I don't feel strongly about it, so I tweaked the code according to
the above.  I'll post it later today.  Thanks,

        Marek

Reply via email to