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 r9-8887] x86: Fix up ix86_atomic_assign_expand_fenv [PR94780] Date: Wed, 16 Sep 2020 19:21:08 +0000 (GMT) [thread overview] Message-ID: <20200916192108.788B83987400@sourceware.org> (raw) https://gcc.gnu.org/g:1777beb6b12983b946dae4177470a319693fc0dc commit r9-8887-g1777beb6b12983b946dae4177470a319693fc0dc Author: Jakub Jelinek <jakub@redhat.com> Date: Mon Apr 27 21:14:52 2020 +0200 x86: Fix up ix86_atomic_assign_expand_fenv [PR94780] This function, because it is sometimes called even outside of function bodies, uses create_tmp_var_raw rather than create_tmp_var. But in order for that to work, when first referenced, the VAR_DECLs need to appear in a TARGET_EXPR so that during gimplification the var gets the right DECL_CONTEXT and is added to local decls. Without that, e.g. tree-nested.c ICEs on those. 2020-04-27 Jakub Jelinek <jakub@redhat.com> PR target/94780 * config/i386/i386.c (ix86_atomic_assign_expand_fenv): Use TARGET_EXPR instead of MODIFY_EXPR for first assignment to sw_var, exceptions_var, mxcsr_orig_var and mxcsr_mod_var. * gcc.dg/pr94780.c: New test. (cherry picked from commit 9b8e9006bb35641865358e2df4f6b3ae185b239a) Diff: --- gcc/config/i386/i386.c | 23 +++++++++++++---------- gcc/testsuite/gcc.dg/pr94780.c | 13 +++++++++++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index c6bc468e36b..5978e51e8ea 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -50943,11 +50943,12 @@ ix86_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) *clear = build_call_expr (fnclex, 0); tree sw_var = create_tmp_var_raw (short_unsigned_type_node); tree fnstsw_call = build_call_expr (fnstsw, 0); - tree sw_mod = build2 (MODIFY_EXPR, short_unsigned_type_node, - sw_var, fnstsw_call); + tree sw_mod = build4 (TARGET_EXPR, short_unsigned_type_node, sw_var, + fnstsw_call, NULL_TREE, NULL_TREE); tree exceptions_x87 = fold_convert (integer_type_node, sw_var); - tree update_mod = build2 (MODIFY_EXPR, integer_type_node, - exceptions_var, exceptions_x87); + tree update_mod = build4 (TARGET_EXPR, integer_type_node, + exceptions_var, exceptions_x87, + NULL_TREE, NULL_TREE); *update = build2 (COMPOUND_EXPR, integer_type_node, sw_mod, update_mod); tree update_fldenv = build_call_expr (fldenv, 1, fenv_addr); @@ -50960,15 +50961,17 @@ ix86_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) tree stmxcsr = ix86_builtins[IX86_BUILTIN_STMXCSR]; tree ldmxcsr = ix86_builtins[IX86_BUILTIN_LDMXCSR]; tree stmxcsr_hold_call = build_call_expr (stmxcsr, 0); - tree hold_assign_orig = build2 (MODIFY_EXPR, unsigned_type_node, - mxcsr_orig_var, stmxcsr_hold_call); + tree hold_assign_orig = build4 (TARGET_EXPR, unsigned_type_node, + mxcsr_orig_var, stmxcsr_hold_call, + NULL_TREE, NULL_TREE); tree hold_mod_val = build2 (BIT_IOR_EXPR, unsigned_type_node, mxcsr_orig_var, build_int_cst (unsigned_type_node, 0x1f80)); hold_mod_val = build2 (BIT_AND_EXPR, unsigned_type_node, hold_mod_val, build_int_cst (unsigned_type_node, 0xffffffc0)); - tree hold_assign_mod = build2 (MODIFY_EXPR, unsigned_type_node, - mxcsr_mod_var, hold_mod_val); + tree hold_assign_mod = build4 (TARGET_EXPR, unsigned_type_node, + mxcsr_mod_var, hold_mod_val, + NULL_TREE, NULL_TREE); tree ldmxcsr_hold_call = build_call_expr (ldmxcsr, 1, mxcsr_mod_var); tree hold_all = build2 (COMPOUND_EXPR, unsigned_type_node, hold_assign_orig, hold_assign_mod); @@ -50997,8 +51000,8 @@ ix86_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) exceptions_assign); } else - *update = build2 (MODIFY_EXPR, integer_type_node, - exceptions_var, exceptions_sse); + *update = build4 (TARGET_EXPR, integer_type_node, exceptions_var, + exceptions_sse, NULL_TREE, NULL_TREE); tree ldmxcsr_update_call = build_call_expr (ldmxcsr, 1, mxcsr_orig_var); *update = build2 (COMPOUND_EXPR, void_type_node, *update, ldmxcsr_update_call); diff --git a/gcc/testsuite/gcc.dg/pr94780.c b/gcc/testsuite/gcc.dg/pr94780.c new file mode 100644 index 00000000000..c4b723e24b2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr94780.c @@ -0,0 +1,13 @@ +/* PR target/94780 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +_Atomic double x; + +double +foo (void) +{ + double bar () { return x; } + x /= 3; + return bar (); +}
reply other threads:[~2020-09-16 19:21 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=20200916192108.788B83987400@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).