public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-670] Fix OMP CAS expansion with separate condition Date: Thu, 19 May 2022 14:27:48 +0000 (GMT) [thread overview] Message-ID: <20220519142748.11A663839C5E@sourceware.org> (raw) https://gcc.gnu.org/g:060173dd73fcaf0767215f9d989ad064e2d5fe2a commit r13-670-g060173dd73fcaf0767215f9d989ad064e2d5fe2a Author: Richard Biener <rguenther@suse.de> Date: Fri May 13 12:07:58 2022 +0200 Fix OMP CAS expansion with separate condition When forcing the condition to be split out from COND_EXPRs I see a runtime failure of libgomp.fortran/atomic-19.f90 which can be reduced to !$omp atomic update, compare, capture if (x == 69_2 - r) x = 6_8 v = x being miscompiled, the difference being - _13 = .ATOMIC_COMPARE_EXCHANGE (_9, _10, _11, 4, 0, 0); - _14 = IMAGPART_EXPR <_13>; - _15 = REALPART_EXPR <_13>; - _16 = _14 != 0 ? _11 : _15; - _2 = (integer(kind=4)) _16; - v_17 = _2; + _14 = .ATOMIC_COMPARE_EXCHANGE (_10, _11, _12, 4, 0, 0); + _15 = IMAGPART_EXPR <_14>; + _16 = REALPART_EXPR <_14>; + _2 = (logical(kind=1)) _15; + _3 = (integer(kind=4)) _16; + v_17 = _3; where one can see a missing COND_EXPR. It seems to be a latent issue to me given the code can be exercised, it just maybe misses a 'need_new' testcase combined with 'cond_stmt'. Appearantly the if (cond_stmt) code is just to avoid creating a temporary (and possibly to preserve the condition compute if used elsewhere since the original stmt is going to be deleted). The following makes the failure go away for me in my patched tree and it also survives libgomp and gomp testing in an unpatched tree. 2022-05-13 Richard Biener <rguenther@suse.de> * omp-expand.cc (expand_omp_atomic_cas): Do not short-cut computation of the new value. Diff: --- gcc/omp-expand.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gcc/omp-expand.cc b/gcc/omp-expand.cc index ee708314793..9fcc67a3448 100644 --- a/gcc/omp-expand.cc +++ b/gcc/omp-expand.cc @@ -9092,16 +9092,17 @@ expand_omp_atomic_cas (basic_block load_bb, tree addr, if (cond_stmt) { - g = gimple_build_assign (gimple_assign_lhs (cond_stmt), - NOP_EXPR, im); + g = gimple_build_assign (cond, NOP_EXPR, im); gimple_set_location (g, loc); gsi_insert_before (&gsi, g, GSI_SAME_STMT); } - else if (need_new) + + if (need_new) { g = gimple_build_assign (create_tmp_reg (itype), COND_EXPR, - build2 (NE_EXPR, boolean_type_node, - im, build_zero_cst (itype)), + cond_stmt + ? cond : build2 (NE_EXPR, boolean_type_node, + im, build_zero_cst (itype)), d, re); gimple_set_location (g, loc); gsi_insert_before (&gsi, g, GSI_SAME_STMT);
reply other threads:[~2022-05-19 14:27 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=20220519142748.11A663839C5E@sourceware.org \ --to=rguenth@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).