]> git.ipfire.org Git - thirdparty/gcc.git/commit
bitint: Fix up lowering of COMPLEX_EXPR [PR115544]
authorJakub Jelinek <jakub@redhat.com>
Wed, 19 Jun 2024 19:10:39 +0000 (21:10 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 19 Jun 2024 19:10:39 +0000 (21:10 +0200)
commit25860fd2a674373a6476af5ff0bd92354fc53d06
tree4b8130fcaa4354df657b698f1edf2d6db0616d41
parent6f6ea27d17e9bbc917b94ffea1c933755e736bdc
bitint: Fix up lowering of COMPLEX_EXPR [PR115544]

We don't really support _Complex _BitInt(N), the only place we use
bitint complex types is for the .{ADD,SUB,MUL}_OVERFLOW internal function
results and COMPLEX_EXPR in the usual case should be either not present
yet because the ifns weren't folded and will be lowered, or optimized
into something simpler, because normally the complex bitint should be
used just for extracting the 2 subparts from it.
Still, with disabled optimizations it can occassionally happen that it
appears in the IL and that is why there is support for lowering those,
but it doesn't handle optimizing those too much, so if it uses SSA_NAME,
it relies on them having a backing VAR_DECL during the lowering.
This is normally achieves through the
                      && ((is_gimple_assign (use_stmt)
                           && (gimple_assign_rhs_code (use_stmt)
                               != COMPLEX_EXPR))
                          || gimple_code (use_stmt) == GIMPLE_COND)
hunk in gimple_lower_bitint, but as the following testcase shows, there
is one thing I've missed, the load optimization isn't guarded by the
above stuff.  So, either we'd need to add support for loads to
lower_complexexpr_stmt, or because they should be really rare, this
patch just disables the load optimization if at least one load use is
a COMPLEX_EXPR (like we do already for PHIs, calls, asm).

2024-06-19  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/115544
* gimple-lower-bitint.cc (gimple_lower_bitint): Disable optimizing
loads used by COMPLEX_EXPR operands.

* gcc.dg/bitint-107.c: New test.
gcc/gimple-lower-bitint.cc
gcc/testsuite/gcc.dg/bitint-107.c [new file with mode: 0644]