]> git.ipfire.org Git - thirdparty/gcc.git/commit
Implement some of fold_binary_op_with_conditional_arg in match.pd
authorRichard Biener <rguenther@suse.de>
Wed, 11 May 2022 09:53:53 +0000 (11:53 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 11 May 2022 12:34:30 +0000 (14:34 +0200)
commit7f04b0d786e13ff5c1bd952a24fd324224415c9a
tree1d4fceaf86289ad02d0c2cc2385346569de8e74d
parent876ac21b7e796f9efb859dfb46ae2a4126b0b782
Implement some of fold_binary_op_with_conditional_arg in match.pd

The following allows (c != 0 ? 0 : 100) != 0 to be simplified as
c != 0 as fold_binary_op_with_conditional_arg would have done
via forwprop and GENERIC folding.  Likewise it allows to combine
(a != 0) != 0 directly via match.pd instead of only via
forwprop and again fold_binary_op_with_conditional_arg.

The patterns do not fully implement all cases of
fold_binary_op_with_conditional_arg, some aspects like
"any of the operands simplify" cannot currently be expressed.

2022-05-11  Richard Biener  <rguenther@suse.de>

* generic-match-head.cc: Include tree-eh.h.
* match.pd ((cond ...) cmp X): New simplification inspired
by fold_binary_op_with_conditional_arg.
(eq/ne (cmp ...) true/false): Likewise.

* gcc.dg/tree-ssa/pr61839_1.c: Adjust.
* gcc.dg/tree-ssa/vrp24.c: Likewise.
gcc/generic-match-head.cc
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/pr61839_1.c
gcc/testsuite/gcc.dg/tree-ssa/vrp24.c