public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1185] expand: Fix up expand_cond_expr_using_cmove [PR106030] Date: Tue, 21 Jun 2022 09:39:48 +0000 (GMT) [thread overview] Message-ID: <20220621093948.566CA3857B91@sourceware.org> (raw) https://gcc.gnu.org/g:2df1df945fac85d7b3d084001414a66a2709d8fe commit r13-1185-g2df1df945fac85d7b3d084001414a66a2709d8fe Author: Jakub Jelinek <jakub@redhat.com> Date: Tue Jun 21 11:38:59 2022 +0200 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.cc (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. Diff: --- gcc/expr.cc | 3 ++- gcc/testsuite/gcc.c-torture/compile/pr106030.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gcc/expr.cc b/gcc/expr.cc index 78c839ab425..c90cde35006 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -8832,7 +8832,8 @@ expand_cond_expr_using_cmove (tree treeop0 ATTRIBUTE_UNUSED, expanding_cond_expr_using_cmove = true; start_sequence (); expand_operands (treeop1, treeop2, - temp, &op1, &op2, EXPAND_NORMAL); + mode == orig_mode ? temp : NULL_RTX, &op1, &op2, + EXPAND_NORMAL); if (TREE_CODE (treeop0) == SSA_NAME && (srcstmt = get_def_for_expr_class (treeop0, tcc_comparison))) diff --git a/gcc/testsuite/gcc.c-torture/compile/pr106030.c b/gcc/testsuite/gcc.c-torture/compile/pr106030.c new file mode 100644 index 00000000000..7514b348ff9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr106030.c @@ -0,0 +1,16 @@ +/* PR middle-end/106030 */ + +int a, b, c; + +char +foo (int x, int y) +{ + return x * y; +} + +void +bar (void) +{ + char d = (foo <= b) * a; + c = foo (2 != bar, d); +}
reply other threads:[~2022-06-21 9:39 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220621093948.566CA3857B91@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).