simplify-rtx: Fix up last argument to simplify_gen_unary [PR113656]
commitb59775b642bb2b1ecd2e6d52c988b9c432117bc8
authorJakub Jelinek <jakub@redhat.com>
Wed, 31 Jan 2024 09:56:56 +0000 (31 10:56 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 31 Jan 2024 10:14:50 +0000 (31 11:14 +0100)
treee79273466aba3da66aef5aa27e58a1523a3013e0
parent457d2b59b58e5998e1e6967316d4e3e8f24edeed
simplify-rtx: Fix up last argument to simplify_gen_unary [PR113656]

When simplifying e.g. (float_truncate:SF (float_truncate:DF (reg:XF))
or (float_truncate:SF (float_extend:XF (reg:DF)) etc. into
(float_truncate:SF (reg:XF)) or (float_truncate:SF (reg:DF)) we call
simplify_gen_unary with incorrect op_mode argument, it should be
the argument's mode, but we call it with the outer mode instead.
As these are all floating point operations, the argument always
has non-VOIDmode and so we can just use that mode (as done in similar
simplifications a few lines later), but neither FLOAT_TRUNCATE nor
FLOAT_EXTEND are operations that should have the same modes of operand
and result.  This bug hasn't been a problem for years because normally
op_mode is used only if the mode of op is VOIDmode, otherwise it is
redundant, but r10-2139 added an assertion in some spots that op_mode
is right even in such cases.

2024-01-31  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/113656
* simplify-rtx.cc (simplify_context::simplify_unary_operation_1)
<case FLOAT_TRUNCATE>: Fix up last argument to simplify_gen_unary.

* gcc.target/i386/pr113656.c: New test.
gcc/simplify-rtx.cc
gcc/testsuite/gcc.target/i386/pr113656.c [new file with mode: 0644]