https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105314
--- Comment #6 from Christoph Müllner <christophm30 at gmail dot com> ---
The proposed fix is triggering an invalid transformation.
The pattern we need to transform is:
Convert "if (test) x = 0;" to "x &= -(test == 0);"
If there is an else branch, we can't apply the transformation.
Error case:
"""
long func2 (long a, long b, long c) // should not be optimized
{
if (c)
a = 0;
else
a = 5;
return a;
}
"""
With the patch this gets compiled to:
0000000000000006 <func2>:
6: 00163513 seqz a0,a2
a: 40a00533 neg a0,a0
e: 8915 andi a0,a0,5
10: 8082 ret