]> git.ipfire.org Git - thirdparty/gcc.git/commit
Restrict :c to commutative ops as intended
authorRichard Biener <rguenther@suse.de>
Thu, 24 Oct 2024 15:06:29 +0000 (17:06 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 25 Oct 2024 09:14:42 +0000 (11:14 +0200)
commit967939055cee4a34729f795042977d99535e061a
tree156e2b05e9c88bcaf25a181576704bb72324eb6a
parent482d5a7b1a4abdd95f42033ad3b8d1276b8fb20a
Restrict :c to commutative ops as intended

genmatch was supposed to restrict :c to verifiable commutative
operations while leaving :C to the "I know what I'm doing" case.
The following enforces this, cleaning up parsing and amending
the commutative_op helper.  There's one pattern that needs adjustment,
the pattern optimizing fmax (x, NaN) or fmax (NaN, x) to x since
fmax isn't commutative.

* genmatch.cc (commutative_op): Add paramter to indicate whether
all compares should be considered commutative.  Handle
hypot, add_overflow and mul_overflow.
(parser::parse_expr): Simplify 'c' handling by using
commutative_op and error out when the operation is not.
* match.pd ((minmax:c @0 NaN@1) -> @0): Use :C, we know
what we are doing.
gcc/genmatch.cc
gcc/match.pd