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>
--- /dev/null
+/* { dg-do compile } */
+/* PR middle-end/120369 */
+
+/* Make sure cabs without a lhs does not cause an ICE. */
+void f()
+{
+ double _Complex z = 1.0;
+ __builtin_cabs(z);
+}
tree lhs = gimple_call_lhs (old_stmt);
+ /* If there is not a LHS, then just keep the statement around. */
+ if (!lhs)
+ return;
+
real_part = extract_component (gsi, arg, false, true);
imag_part = extract_component (gsi, arg, true, true);
location_t loc = gimple_location (old_stmt);