Re: [PATCH v2] MATCH: fold signbit comparison and conditional negate to copysign [PR109843]
Jakub Jelinek <[email protected]>
| Newsgroups | gmane.comp.gcc.patches |
|---|---|
| Message-ID | <amu8Dg_Wdtoflo9k@tucnak> |
On Fri, Jul 24, 2026 at 05:14:11PM -0600, Jeffrey Law wrote: > > > On 7/23/2026 1:11 AM, Eikansh Gupta wrote: > > Fold (signbit (x) cmp1 0) cmp (signbit (y) cmp2 0) ? y : -y > > to copysign (y, +-x). The result keeps the magnitude of Y and takes its > > sign from X (or -X). Emitted as IFN_COPYSIGN when the target supports it. > > > > PR tree-optimization/109843 > > > > gcc/ChangeLog: > > > > * match.pd ((signbit (x) cmp 0) cmp (signbit (y) cmp 0) ? y : -y): > > New simplification to copysign (y, +-x). > > > > gcc/testsuite/ChangeLog: > > > > * gcc.dg/tree-ssa/pr109843.c: New test. > > > > Signed-off-by: Eikansh Gupta <[email protected]> > OK. Please commit to the trunk. This test FAILs for me, both on i686-linux and on x86_64-linux too, on the latter with RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} tree-ssa.exp=pr109843.c' PASS: gcc.dg/tree-ssa/pr112472.c (test for excess errors) PASS: gcc.dg/tree-ssa/pr112472.c scan-tree-dump-not optimized "= __builtin_copysign" FAIL: gcc.dg/tree-ssa/pr112472.c scan-tree-dump-not optimized " double " gcc.dg/tree-ssa/pr112472.c: pattern found 0 times FAIL: gcc.dg/tree-ssa/pr112472.c scan-tree-dump-times optimized ".COPYSIGN" 1 gcc.dg/tree-ssa/pr112472.c: pattern found 0 times FAIL: gcc.dg/tree-ssa/pr112472.c scan-tree-dump-times optimized "-1.0e\\+0" 1 gcc.dg/tree-ssa/pr112472.c: pattern found 2 times FAIL: gcc.dg/tree-ssa/pr112472.c scan-tree-dump-times optimized " ABS_EXPR " 1 during the lower pass __builtin_copysign is lowered to -ABS_EXPR etc. Jakub