]> git.ipfire.org Git - thirdparty/gcc.git/commit
MATCH: Add pattern for `signbit(x) ? x : -x` into abs (and swapped)
authorAndrew Pinski <apinski@marvell.com>
Sat, 13 May 2023 22:25:21 +0000 (22:25 +0000)
committerAndrew Pinski <apinski@marvell.com>
Sun, 14 May 2023 19:58:50 +0000 (19:58 +0000)
commit82502b5c3463bde98d4b7ffb9ecef9b123799ed1
tree0f5c205cfbbebf0547be5ecfc2a6e8fa405c87a0
parentaed51e2051b24a6a2127c6626f451641557a571a
MATCH: Add pattern for `signbit(x) ? x : -x` into abs (and swapped)

This adds a simple pattern to match.pd for `signbit(x) ? x : -x`
into abs<x>. This can be done for all types even ones that honor
signed zeros and NaNs because both signbit and - are considered
only looking at/touching the sign bit of those types and does
not trap either.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR tree-optimization/109829

gcc/ChangeLog:

* match.pd: Add pattern for `signbit(x) !=/== 0 ? x : -x`.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/abs-3.c: New test.
* gcc.dg/tree-ssa/abs-4.c: New test.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/abs-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/abs-4.c [new file with mode: 0644]