]> git.ipfire.org Git - thirdparty/gcc.git/commit
match: Keep conditional in simplification to constant [PR118140].
authorRobin Dapp <rdapp@ventanamicro.com>
Fri, 27 Dec 2024 16:29:25 +0000 (17:29 +0100)
committerRobin Dapp <rdapp@ventanamicro.com>
Tue, 14 Jan 2025 11:52:32 +0000 (12:52 +0100)
commit14cb0610559fa33f211e1546260458496fdc5e71
tree68ed735874079a93ca9859044baa1d4ac2db6342
parent87ffd205fe0f4cbabd3d22cba815b02c0466d9ed
match: Keep conditional in simplification to constant [PR118140].

In PR118140 we simplify

  _ifc__33 = .COND_IOR (_41, d_lsm.7_11, _46, d_lsm.7_11);

to 1:

Match-and-simplified .COND_IOR (_41, d_lsm.7_11, _46, d_lsm.7_11) to 1

when _46 == 1.  This happens by removing the conditional and applying
a | 1 = 1.  Normally we re-introduce the conditional and its else value
if needed but that does not happen here as we're not dealing with a
vector type.  For correctness's sake, we must not remove the conditional
even for non-vector types.

This patch re-introduces a COND_EXPR in such cases.  For PR118140 this
result in a non-vectorized loop.

PR middle-end/118140

gcc/ChangeLog:

* gimple-match-exports.cc (maybe_resimplify_conditional_op): Add
COND_EXPR when we simplified to a scalar gimple value but still
have an else value.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/pr118140.c: New test.
* gcc.target/riscv/rvv/autovec/pr118140.c: New test.
gcc/gimple-match-exports.cc
gcc/testsuite/gcc.dg/vect/pr118140.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/autovec/pr118140.c [new file with mode: 0644]