On 9/24/24 2:57 AM, Eikansh Gupta wrote:
This patch simplify `(trunc)copysign ((extend)x, CST)` to `copysign (x, 
-1.0/1.0)`
depending on the sign of CST. Previously, it was simplified to `copysign (x, 
CST)`.
It can be optimized as the sign of the CST matters, not the value.

The patch also simplify `(trunc)abs (extend x)` to `abs (x)`.

        PR tree-optimization/112472

gcc/ChangeLog:

        * match.pd ((trunc)copysign ((extend)x, -CST) --> copysign (x, -1.0)): 
New pattern.
        ((trunc)abs (extend x) --> abs (x)): New pattern.

gcc/testsuite/ChangeLog:

        * gcc.dg/tree-ssa/pr112472.c: New test.
One might argue that -0.0/+0.0 are even better than -1.0/1.0 as the 0.0 variants are cheaper to construct.

You'd have to check that we honor signed zeros....

jeff

Reply via email to