From: Jeff Law <jeffreyalaw@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Check optab before transforming atomic bit test and operations
Date: Mon, 15 Nov 2021 12:14:28 -0700 [thread overview]
Message-ID: <42a52a7d-095d-25a4-c567-471214e61e38@gmail.com> (raw)
In-Reply-To: <CAMe9rOpXmuw=zBJk=idGZpEreo127UJH=itWt-Qa05Wt36GWFg@mail.gmail.com>
On 11/15/2021 12:05 PM, H.J. Lu wrote:
> On Mon, Nov 15, 2021 at 10:59 AM Jeff Law <jeffreyalaw@gmail.com> wrote:
>>
>>
>> On 11/15/2021 6:39 AM, H.J. Lu via Gcc-patches wrote:
>>> Check optab before transforming equivalent, but slighly different cases
>>> of atomic bit test and operations to their canonical forms.
>>>
>>> gcc/
>>>
>>> PR middle-end/103184
>>> * tree-ssa-ccp.c (optimize_atomic_bit_test_and): Check optab
>>> before transforming equivalent, but slighly different cases to
>>> their canonical forms.
>>>
>>> gcc/testsuite/
>>>
>>> PR middle-end/103184
>>> * gcc.dg/pr103184-1.c: New test.
>>> * gcc.dg/pr103184-2.c: Likewise.
>>> }
>>> }
>>>
>>> - switch (fn)
>>> - {
>>> - case IFN_ATOMIC_BIT_TEST_AND_SET:
>>> - optab = atomic_bit_test_and_set_optab;
>>> - break;
>>> - case IFN_ATOMIC_BIT_TEST_AND_COMPLEMENT:
>>> - optab = atomic_bit_test_and_complement_optab;
>>> - break;
>>> - case IFN_ATOMIC_BIT_TEST_AND_RESET:
>>> - optab = atomic_bit_test_and_reset_optab;
>>> - break;
>>> - default:
>>> - return;
>>> - }
>>> -
>>> if (optab_handler (optab, TYPE_MODE (TREE_TYPE (lhs))) == CODE_FOR_nothing)
>>> return;
>> Shouldn't the test of the return value of optab_handler here just go
>> away since we're testing it earlier? OK with that fix.
>>
> The earlier check is predicated on if (rhs_code != BIT_AND_EXPR):
>
> if (rhs_code != BIT_AND_EXPR)
> {
> if (rhs_code != NOP_EXPR && rhs_code != BIT_NOT_EXPR)
> return;
>
> tree use_lhs = gimple_assign_lhs (use_stmt);
> if (TREE_CODE (use_lhs) == SSA_NAME
> && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (use_lhs))
> return;
>
> tree use_rhs = gimple_assign_rhs1 (use_stmt);
> if (lhs != use_rhs)
> return;
>
> if (optab_handler (optab, TYPE_MODE (TREE_TYPE (lhs)))
> == CODE_FOR_nothing)
> return;
>
> I can add an "else"
>
> else if (optab_handler (optab, TYPE_MODE (TREE_TYPE (lhs)))
> == CODE_FOR_nothing)
> return;
>
> Will it be OK?
Sure. THanks.
jeff
next prev parent reply other threads:[~2021-11-15 19:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-15 13:39 H.J. Lu
2021-11-15 18:59 ` Jeff Law
2021-11-15 19:05 ` H.J. Lu
2021-11-15 19:14 ` Jeff Law [this message]
2021-11-15 20:58 ` [PATCH v2] " H.J. Lu
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=42a52a7d-095d-25a4-c567-471214e61e38@gmail.com \
--to=jeffreyalaw@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hjl.tools@gmail.com \
/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: link
Be 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).