https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94589
--- Comment #31 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <[email protected]>: https://gcc.gnu.org/g:ea8c74c074925b93f013519a63e3518e0c448b85 commit r17-2129-gea8c74c074925b93f013519a63e3518e0c448b85 Author: Andrew Pinski <[email protected]> Date: Tue Jun 30 12:13:05 2026 -0700 match: Simplify `(a CMP1 b) AND/IOR (a CMP2 b)` [PR126042] This finishes up simplifications of most comparisons outside of reassociation. Including but not limited to many floating point comparisons. Instead of redoing what is done in fold-cost.cc's combine_comparisons, this reuses combine_comparisons to find the new CMP. In the case of `-fno-trapping-math`, this allows to optimize `<=>` which it was not before. Changes since v1: * v2: Fix some typos. Add a C testcase. Bootstrapped and tested on x86_64-linux-gnu. PR tree-optimization/106164 PR tree-optimization/126042 PR tree-optimization/94589 gcc/ChangeLog: * fold-const.cc (combine_comparisons): Split into 2 versions. Also handle BIT_AND_EXPR and BIT_IOR_EXPR. * fold-const.h (combine_comparisons): New declaration. * match.pd (`(a CMP1 b) BITOP (a CMP2 b)`): New pattern. gcc/testsuite/ChangeLog: * g++.dg/opt/pr94589-5a.C: New test. * gcc.dg/pr94589-5.c: Explictly enable -ftrapping-math. * gcc.dg/pr94589-5a.c: New test. Signed-off-by: Andrew Pinski <[email protected]>
