]> git.ipfire.org Git - thirdparty/gcc.git/commit
expand: Fix up expand_cond_expr_using_cmove [PR106030]
authorJakub Jelinek <jakub@redhat.com>
Tue, 21 Jun 2022 09:38:59 +0000 (11:38 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 3 May 2023 11:16:15 +0000 (13:16 +0200)
commit89741783f6e7127d4d8be5a5e8e4fb7d5785f8a6
treee26f87b7790709dccc3ef857bd83d666b3c4d700
parent58c396a2ce4f8f66e6c379d74e834e3c8d93f36b
expand: Fix up expand_cond_expr_using_cmove [PR106030]

If expand_cond_expr_using_cmove can't find a cmove optab for a particular
mode, it tries to promote the mode and perform the cmove in the promoted
mode.

The testcase in the patch ICEs on arm because in that case we pass temp which
has the promoted mode (SImode) as target to expand_operands where the
operands have the non-promoted mode (QImode).
Later on the function uses paradoxical subregs:
  if (GET_MODE (op1) != mode)
    op1 = gen_lowpart (mode, op1);

  if (GET_MODE (op2) != mode)
    op2 = gen_lowpart (mode, op2);
to change the operand modes.

The following patch fixes it by passing NULL_RTX as target if it has
promoted mode.

2022-06-21  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/106030
* expr.c (expand_cond_expr_using_cmove): Pass NULL_RTX instead of
temp to expand_operands if mode has been promoted.

* gcc.c-torture/compile/pr106030.c: New test.

(cherry picked from commit 2df1df945fac85d7b3d084001414a66a2709d8fe)
gcc/expr.c
gcc/testsuite/gcc.c-torture/compile/pr106030.c [new file with mode: 0644]