]> git.ipfire.org Git - thirdparty/gcc.git/commit
move the (a-b) CMP 0 ? (a-b) : (b-a) optimization from fold_cond_expr_with_comparison...
authorAndrew Pinski <apinski@marvell.com>
Sun, 11 Jul 2021 01:41:27 +0000 (18:41 -0700)
committerAndrew Pinski <pinskia@gmail.com>
Mon, 23 Oct 2023 10:55:15 +0000 (03:55 -0700)
commit1acd4576435974f36dc91a8cc707cdcdccd049be
tree3defdbd04685cc135c325fbd214db9d3cf9fed9c
parent85e930ac8557c444680b5b29a0a13a14ea6672b5
move the (a-b) CMP 0 ? (a-b) : (b-a) optimization from fold_cond_expr_with_comparison to match

This patch moves the `(a-b) CMP 0 ? (a-b) : (b-a)` optimization
from fold_cond_expr_with_comparison to match.

Bootstrapped and tested on x86_64-linux-gnu.

Changes in:
v2: Removes `(a == b) ? 0 : (b - a)` handling since it was handled
    via r14-3606-g3d86e7f4a8ae
    Change zerop to integer_zerop for `(a - b) == 0 ? 0 : (b - a)`,
    Add `(a - b) != 0 ? (a - b) : 0` handling.

gcc/ChangeLog:

* match.pd (`(A - B) CMP 0 ? (A - B) : (B - A)`):
New patterns.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/phi-opt-38.c: New test.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-38.c [new file with mode: 0644]