Canonicalize argument order for commutative functions
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 30 Nov 2021 09:52:25 +0000 (09:52 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 30 Nov 2021 09:52:25 +0000 (09:52 +0000)
commite9fff24cd2b365a236fcb31bdf186f6ec9e00f76
tree8bf1c8fe2dcdb1f22fe4a1eafb002f6ceb1b2872
parente32b9eb32d7cd2d39bf9c70497890ac61b9ee14c
Canonicalize argument order for commutative functions

This patch uses information about internal functions to canonicalize
the argument order of calls.

gcc/
* gimple-fold.c: Include internal-fn.h.
(fold_stmt_1): If a function maps to an internal one, use
first_commutative_argument to canonicalize the order of
commutative arguments.
* gimple-match-head.c (gimple_resimplify2, gimple_resimplify3)
(gimple_resimplify4, gimple_resimplify5): Extend commutativity
checks to functions.

gcc/testsuite/
* gcc.dg/fmax-fmin-1.c: New test.
gcc/gimple-fold.c
gcc/gimple-match-head.c
gcc/testsuite/gcc.dg/fmax-fmin-1.c [new file with mode: 0644]