From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id 6634E3846414; Mon, 28 Nov 2022 14:29:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6634E3846414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669645799; bh=zVvz1/bkMjUJkCEyy/TNVu05rTstU++2sl4SxdTSUm4=; h=From:To:Subject:Date:From; b=NUKrNREay76UJ1wQsAuH9D6Ra9u705eq9EOV8SuEbev36qNnJTn9O4OUo4SXy+R3L bTKVccjmW4OdDnEPJj7OQdwS3xwmo97tkUURkzaixcInkhKFuDQV4RHKxxu5Ozy5ox 7nEBVDtsKo8OkYmsYkeQGALbFEpw3ySprjpQaSBY= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-12] gcn: Fix __builtin_gcn_first_call_this_thread_p X-Act-Checkin: gcc X-Git-Author: Tobias Burnus X-Git-Refname: refs/heads/devel/omp/gcc-12 X-Git-Oldrev: 519f647c57f1c56b4d333949a9786395bf48295f X-Git-Newrev: ec5445902910ad709f33a0f13fcd314b3d4e3e87 Message-Id: <20221128142959.6634E3846414@sourceware.org> Date: Mon, 28 Nov 2022 14:29:59 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ec5445902910ad709f33a0f13fcd314b3d4e3e87 commit ec5445902910ad709f33a0f13fcd314b3d4e3e87 Author: Tobias Burnus Date: Mon Nov 28 15:21:30 2022 +0100 gcn: Fix __builtin_gcn_first_call_this_thread_p Contrary naive expectation, unspec_volatile (via prologue_use) did not prevent the cprop pass (at -O2) to remove the access to the s[0:1] (PRIVATE_SEGMENT_BUFFER_ARG) register as the volatile got just put on the preceeding pseudoregister. Solution: Use gen_rtx_USE instead. Additionally, this patch removes (gen_)prologue_use_di as it is then no longer used. Finally, as we already do bit manipulation, instead of using the full 64bit side - and then just keeping the value of 's0', just move directly to use only s1 of s[0:1] and do the bit manipulations there, generating more readable assembly code and better matching the '#else' branch. gcc/ChangeLog: * config/gcn/gcn.cc (gcn_expand_builtin_1): Work on s1 instead of s[0:1] and use USE to prevent removal of setting that register. * config/gcn/gcn.md (prologue_use_di): Remove. (cherry picked from commit 9fa67f1c1228a852e23943a41e68b664172c654c) Diff: --- gcc/ChangeLog.omp | 9 +++++++++ gcc/config/gcn/gcn.cc | 16 ++++++++-------- gcc/config/gcn/gcn.md | 13 ------------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index f8a49af7620..48443438e39 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,12 @@ +2022-11-28 Tobias Burnus + + Backported from master: + 2022-11-28 Tobias Burnus + + * config/gcn/gcn.cc (gcn_expand_builtin_1): Work on s1 instead + of s[0:1] and use USE to prevent removal of setting that register. + * config/gcn/gcn.md (prologue_use_di): Remove. + 2022-11-26 Sandra Loosemore Backported from master: diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc index 48a80ba103c..85f20a46d67 100644 --- a/gcc/config/gcn/gcn.cc +++ b/gcc/config/gcn/gcn.cc @@ -4589,8 +4589,9 @@ gcn_expand_builtin_1 (tree exp, rtx target, rtx /*subtarget */ , rtx not_first = gen_label_rtx (); rtx reg = gen_rtx_REG (DImode, cfun->machine->args.reg[PRIVATE_SEGMENT_BUFFER_ARG]); - rtx cmp = force_reg (DImode, - gen_rtx_LSHIFTRT (DImode, reg, GEN_INT (48))); + reg = gcn_operand_part (DImode, reg, 1); + rtx cmp = force_reg (SImode, + gen_rtx_LSHIFTRT (SImode, reg, GEN_INT (16))); emit_insn (gen_cstoresi4 (result, gen_rtx_NE (BImode, cmp, GEN_INT(12345)), cmp, GEN_INT(12345))); @@ -4598,12 +4599,11 @@ gcn_expand_builtin_1 (tree exp, rtx target, rtx /*subtarget */ , const0_rtx), result)); emit_move_insn (reg, - force_reg (DImode, - gen_rtx_IOR (DImode, - gen_rtx_AND (DImode, reg, - GEN_INT (0x0000ffffffffffffL)), - GEN_INT (12345L << 48)))); - emit_insn (gen_prologue_use (reg)); + force_reg (SImode, + gen_rtx_IOR (SImode, + gen_rtx_AND (SImode, reg, GEN_INT (0x0000ffff)), + GEN_INT (12345L << 16)))); + emit_insn (gen_rtx_USE (VOIDmode, reg)); emit_label (not_first); } return result; diff --git a/gcc/config/gcn/gcn.md b/gcc/config/gcn/gcn.md index f31c20471da..7e803f738bc 100644 --- a/gcc/config/gcn/gcn.md +++ b/gcc/config/gcn/gcn.md @@ -726,19 +726,6 @@ "" [(set_attr "length" "0")]) -(define_insn_and_split "prologue_use_di" - [(unspec_volatile [(match_operand:DI 0 "register_operand")] UNSPECV_PROLOGUE_USE)] - "" - "#" - "reload_completed" - [(unspec_volatile [(match_dup 0)] UNSPECV_PROLOGUE_USE) - (unspec_volatile [(match_dup 1)] UNSPECV_PROLOGUE_USE)] - { - operands[1] = gcn_operand_part (DImode, operands[0], 1); - operands[0] = gcn_operand_part (DImode, operands[0], 0); - } - [(set_attr "length" "0")]) - (define_expand "prologue" [(const_int 0)] ""