]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix PR 110874: infinite loop in gimple_bitwise_inverted_equal_p with fre
authorAndrew Pinski <apinski@marvell.com>
Wed, 2 Aug 2023 21:49:00 +0000 (14:49 -0700)
committerAndrew Pinski <apinski@marvell.com>
Fri, 4 Aug 2023 07:26:42 +0000 (00:26 -0700)
commit91c963ea6f845a0c59b7523a5330b8d3ed1beb6a
treea136a83a6373501d95d2d46de5937fdf82d8535a
parent9020da78df2854f14f8b1d38b58a6d3b77a4b731
Fix PR 110874: infinite loop in gimple_bitwise_inverted_equal_p with fre

This changes gimple_bitwise_inverted_equal_p to use a 2 different match patterns
to try to match bit_not wrapped with a possible nop_convert and a comparison
also wrapped with a possible nop_convert. This is to avoid being recursive.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

PR tree-optimization/110874
* gimple-match-head.cc (gimple_bit_not_with_nop): New declaration.
(gimple_maybe_cmp): Likewise.
(gimple_bitwise_inverted_equal_p): Rewrite to use gimple_bit_not_with_nop
and gimple_maybe_cmp instead of being recursive.
* match.pd (bit_not_with_nop): New match pattern.
(maybe_cmp): Likewise.

gcc/testsuite/ChangeLog:

PR tree-optimization/110874
* gcc.c-torture/compile/pr110874-a.c: New test.
gcc/gimple-match-head.cc
gcc/match.pd
gcc/testsuite/gcc.c-torture/compile/pr110874-a.c [new file with mode: 0644]