On Thu, Aug 20, 2015 at 12:58 PM, Richard Biener
<[email protected]> wrote:
> On Thu, Aug 20, 2015 at 11:18 AM, Hurugalawadi, Naveen
> <[email protected]> wrote:
>> Hi,
>>
>>>> Works for me if you specify -fno-math-errno. I think that's a
>>>> "regression" we can accept.
>>
>> Modified the pattern with "fno-math-errno" as a condition.
>>
>>>> Can you re-post with the typo fix and the missing :s?
>>
>> Please find attached the modified patch as per the review comments.
>> Please suggest if there should be any further modifications.
>
> You marked
>
> + /* Simplify x * pow(x,c) -> pow(x,c+1). */
> + (simplify
> + (mult @0 (POW:s @0 REAL_CST@1))
> + (if (!flag_errno_math
> + && !TREE_OVERFLOW (@1))
> + (POW @0 (plus @1 { build_one_cst (type); }))))
>
> with !flag_errno_math to avoid ICEs when replacing a non-call with a call.
> But ...
I have now committed a patch for PR67285 so your patch is ok now if
you remove that !flag_errno_math check above.
Thanks,
Richard.
> + /* Simplify sin(x) / cos(x) -> tan(x). */
> + (simplify
> + (rdiv (SIN:s @0) (COS:s @0))
> + (TAN @0))
>
> has exactly the same issue, so does the following (and maybe others)
>
> + /* Simplify cos(x) / sin(x) -> 1 / tan(x). */
> + (simplify
> + (rdiv (COS:s @0) (SIN:s @0))
> + (rdiv { build_one_cst (type); } (TAN @0)))
>
> so I presume those simply do not trigger late (on GIMPLE) for any existing
> testcases.
>
> So to not expose this (latent) issue please wait until I find the time to fix
> the underlying issue in a more generic way. I will have a look today.
>
> Thanks,
> Richard.
>
>> Thanks,
>> Naveen
>>
>> ChangeLog
>>
>> 2015-08-20 Naveen H.S <[email protected]>
>>
>> * fold-const.c (fold_binary_loc) : Move sqrt(x)*sqrt(x) as x
>> to match.pd.
>> Move Optimize pow(x,y)*pow(z,y) as pow(x*z,y)to match.pd.
>> Move Optimize tan(x)*cos(x) as sin(x) to match.pd.
>> Move Optimize x*pow(x,c) as pow(x,c+1) to match.pd.
>> Move Optimize pow(x,c)*x as pow(x,c+1) to match.pd.
>> Move Optimize sin(x)/cos(x) as tan(x) to match.pd.
>> Move Optimize cos(x)/sin(x) as 1.0/tan(x) to match.pd.
>> Move Optimize sin(x)/tan(x) as cos(x) to match.pd.
>> Move Optimize tan(x)/sin(x) as 1.0/cos(x) to match.pd.
>> Move Optimize pow(x,c)/x as pow(x,c-1) to match.pd.
>> Move Optimize x/pow(y,z) into x*pow(y,-z) to match.pd.
>>
>> * match.pd (SIN ) : New Operator.
>> (TAN) : New Operator.
>> (mult (SQRT@1 @0) @1) : New simplifier.
>> (mult (POW:s @0 @1) (POW:s @2 @1)) : New simplifier.
>> (mult:c (TAN:s @0) (COS:s @0)) : New simplifier.
>> (mult:c (TAN:s @0) (COS:s @0)) : New simplifier.
>> (rdiv (SIN:s @0) (COS:s @0)) : New simplifier.
>> (rdiv (COS:s @0) (SIN:s @0)) : New simplifier.
>> (rdiv (SIN:s @0) (TAN:s @0)) : New simplifier.
>> (rdiv (TAN:s @0) (SIN:s @0)) : New simplifier.
>> (rdiv (POW:s @0 REAL_CST@1) @0) : New simplifier.
>> (rdiv @0 (SQRT:s (rdiv:s @1 @2))) : New simplifier.
>> (rdiv @0 (POW:s @1 @2)) : New simplifier.