]> 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>
Thu, 3 Jul 2025 17:32:43 +0000 (10:32 -0700)
commit2cb1108c0929311f73fc9210d29681ba49607b8d
treeb390284be3990bdb3ba408800de25cd36d343196
parent612690936f5ddd122b60cf843cb4f40ae7ede436
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>
(cherry picked from commit 95c74f354ae3186e84fbada22d2e7f3845dbb659)
gcc/testsuite/gcc.dg/torture/pr120369-1.c [new file with mode: 0644]
gcc/tree-complex.cc