]> git.ipfire.org Git - thirdparty/gcc.git/commit
MATCH: Fix infinite loop between `vec_cond(vec_cond(a,b,0), c, d)` and `a & b`
authorAndrew Pinski <pinskia@gmail.com>
Thu, 5 Oct 2023 19:21:19 +0000 (12:21 -0700)
committerAndrew Pinski <pinskia@gmail.com>
Sat, 7 Oct 2023 19:45:02 +0000 (12:45 -0700)
commitadd2afa9e25f1776fdfbeb1b99fd1efcf850f91f
treedf29524c6e85477ee066d487ca0b36e66ba18cbc
parente9e0b9e408fd59ed64b92b4ee6ea69baf517d99b
MATCH: Fix infinite loop between `vec_cond(vec_cond(a,b,0), c, d)` and `a & b`

Match has a pattern which converts `vec_cond(vec_cond(a,b,0), c, d)`
into `vec_cond(a & b, c, d)` but since in this case a is a comparison
fold will change `a & b` back into `vec_cond(a,b,0)` which causes an
infinite loop.
The best way to fix this is to enable the patterns for vec_cond(*,vec_cond,*)
only for GIMPLE so we don't get an infinite loop for fold any more.

Note this is a latent bug since these patterns were added in r11-2577-g229752afe3156a
and was exposed by r14-3350-g47b833a9abe1 where now able to remove a VIEW_CONVERT_EXPR.

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

PR middle-end/111699

gcc/ChangeLog:

* match.pd ((c ? a : b) op d, (c ? a : b) op (c ? d : e),
(v ? w : 0) ? a : b, c1 ? c2 ? a : b : b): Enable only for GIMPLE.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/pr111699-1.c: New test.

(cherry picked from commit e77428a9a336f57e3efe3eff95f2b491d7e9be14)
gcc/match.pd
gcc/testsuite/gcc.c-torture/compile/pr111699-1.c [new file with mode: 0644]