This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] (-fstrict-overflow) optimize counted loops on signed iv


On 2/15/07, Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz> wrote:
Hello,

> >> On 2/15/07, Christian BRUEL <christian.bruel@st.com> wrote:
> >> >for my curiosity, I just had a quick look at fold-const and it looks
> >> >like 'fold_relational_const' only handle the case were ops are
> >INTEGER_CST
> >> >:
> >>
> >> Look in fold_comparison instead.  This is already handled.
> >
> >no it is not (or at least, I cannot find it anywhere, and the
> >transformations do not seem to be performed)?
>
> I thought this one in fold_binary should handle it:
>
>    case LT_EXPR:
>    case GT_EXPR:
>    case LE_EXPR:
>    case GE_EXPR:
>      tem = fold_comparison (code, type, op0, op1);
>      if (tem != NULL_TREE)
>        return tem;
>
>      /* Transform comparisons of the form X +- C CMP X.  */
>      if ((TREE_CODE (arg0) == PLUS_EXPR || TREE_CODE (arg0) == MINUS_EXPR)
>          && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)
>          && ((TREE_CODE (TREE_OPERAND (arg0, 1)) == REAL_CST
>               && !HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg0))))
>              || (TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
>                  && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))))
>        {
> ...

I think this is what Christian claimed, that we handle only the
case x + cst cmp x?

Btw. if you wonder why we do not fold the comparison in his testcase,
the reason is that the code in fold_binary does not handle the case
x cmp x + cst...

But that's not the canonical form... this is transformed to x + cst cmp x first and then folded.

Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]