On 6/30/2026 8:07 PM, Odysseas Georgoudis wrote:
 This patch teaches match.pd to recognize the branchless conditional
 negate idiom

   (x ^ -cmp) + cmp

 when cmp is known to be zero or one.  The expression is folded to a
 conditional negate form.  For the sign-test spelling based on x < 0,
 the patch exposes ABS_EXPR.

 I could not comment on the PR because my GCC Bugzilla account is still
 pending, so I am sending the patch here.

 Bootstrapped on x86_64-pc-linux-gnu.  Tested with
 gcc.dg/tree-ssa/tree-ssa.exp and the new gcc.dg/tree-ssa/pr113894.c
 testcase.

 I do not have commit access.

​pr113894.patch <https://1drv.ms/u/c/5a41b3fa58bb8071/IQAXsKqhUTaaQb_gOXEu4L8RAXgQUmxYo5d_eBzRtnqcKSI>​
Can you include the patch in your message.  It looks like the link goes to onedrive and I suspect many folks aren't going to want to do that.

Interestingly enough the (x ^ -cmp) + cmp form is probably optimal on RISC-V, so hopefully even after your match.pd change we'll still be able to recover optimal form across different designs.

jeff

Reply via email to