]> git.ipfire.org Git - thirdparty/gcc.git/commit
middle-end: Fix complex lowering of cabs with no LHS [PR120369]
authorAndrew Pinski <quic_apinski@quicinc.com>
Tue, 20 May 2025 20:21:28 +0000 (13:21 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Wed, 21 May 2025 04:32:44 +0000 (21:32 -0700)
commit95c74f354ae3186e84fbada22d2e7f3845dbb659
tree7f8f39ba318d93ea0fdc7c1c968fe22c56a92385
parent5568277c005f5edda0ce444e11abd1d5845d6ee7
middle-end: Fix complex lowering of cabs with no LHS [PR120369]

This was introduced by r15-1797-gd8fe4f05ef448e . I had missed that
the LHS of the cabs call could be NULL. This seems to only happen at -O0,
I tried to produce one that happens at -O1 but needed many different
options to prevent the removal of the call.
Anyways the fix is just keep around the call if the LHS is null.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/120369

gcc/ChangeLog:

* tree-complex.cc (gimple_expand_builtin_cabs): Return early
if the LHS of cabs is null.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr120369-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/testsuite/gcc.dg/torture/pr120369-1.c [new file with mode: 0644]
gcc/tree-complex.cc