From: "juzhe.zhong@rivai.ai" <juzhe.zhong@rivai.ai>
To: richard.sandiford <richard.sandiford@arm.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, rguenther <rguenther@suse.de>
Subject: Re: Re: [PATCH V4] VECT: Add decrement IV iteration loop control by variable amount support
Date: Thu, 11 May 2023 13:14:07 +0800 [thread overview]
Message-ID: <1F244094F9BCED03+20230511131407104447194@rivai.ai> (raw)
In-Reply-To: <mptbkirii9z.fsf@arm.com>
[-- Attachment #1: Type: text/plain, Size: 3136 bytes --]
Thank you so much.
Can you take a look at this patch:
https://gcc.gnu.org/pipermail/gcc-patches/2023-May/618110.html
Thanks.
juzhe.zhong@rivai.ai
From: Richard Sandiford
Date: 2023-05-11 12:50
To: 钟居哲
CC: gcc-patches; rguenther
Subject: Re: [PATCH V4] VECT: Add decrement IV iteration loop control by variable amount support
钟居哲 <juzhe.zhong@rivai.ai> writes:
> I am sorry that I am still confused about that.
>
> Is this what you want ?
>
> bool use_minus_p = TREE_CODE (step) == INTEGER_CST && ((TYPE_UNSIGNED (TREE_TYPE (step)) && tree_int_cst_lt (step1, step))
> || (!TYPE_UNSIGNED (TREE_TYPE (step)) && !tree_expr_nonnegative_warnv_p (step, &ovf) && may_negate_without_overflow_p (step)));
>
> /* For easier readability of the created code, produce MINUS_EXPRs
> when suitable. */
> if (TREE_CODE (step) == INTEGER_CST)
> {
> if (TYPE_UNSIGNED (TREE_TYPE (step)))
> {
> step1 = fold_build1 (NEGATE_EXPR, TREE_TYPE (step), step);
> if (tree_int_cst_lt (step1, step))
> {
> incr_op = MINUS_EXPR; /* Remove it. */
> step = step1;
> }
> }
> else
> {
> bool ovf;
>
> if (!tree_expr_nonnegative_warnv_p (step, &ovf)
> && may_negate_without_overflow_p (step))
> {
> incr_op = MINUS_EXPR; /* Remove it. */
> step = fold_build1 (NEGATE_EXPR, TREE_TYPE (step), step);
> }
> }
> }
> if (POINTER_TYPE_P (TREE_TYPE (base)))
> {
> if (TREE_CODE (base) == ADDR_EXPR)
> mark_addressable (TREE_OPERAND (base, 0));
> step = convert_to_ptrofftype (step);
> if (incr_op == MINUS_EXPR) /* Change it into if (use_minus_p) */
> step = fold_build1 (NEGATE_EXPR, TREE_TYPE (step), step);
> incr_op = POINTER_PLUS_EXPR; /* Remove it. */
> }
> /* Gimplify the step if necessary. We put the computations in front of the
> loop (i.e. the step should be loop invariant). */
> step = force_gimple_operand (step, &stmts, true, NULL_TREE);
> if (stmts)
> gsi_insert_seq_on_edge_immediate (pe, stmts);
>
> if (POINTER_TYPE_P (TREE_TYPE (base)))
> stmt = gimple_build_assign (va, POINTER_PLUS_EXPR, vb, step);
> else if (use_minus_p)
> stmt = gimple_build_assign (va, MINUS_EXPR, vb, step);
> else
> stmt = gimple_build_assign (va, incr_op, vb, step);
> ...
>
> Since I have no idea to make stmts flips between PLUS_EXPR and MINUS_EXPR.
No, I meant:
- Rename the "code" argument to "incr_op".
- Remove "tree_code incr_op = code;".
- Replace both instances of:
incr_op = MINUS_EXPR;
with:
incr_op = (incr_op == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR);
The point is that the current code (rightly) assumes that incr_op
always starts out as PLUS_EXPR, i.e. that STEP starts out applying
positively. Making STEP apply in the opposite direction is then as
simple as changing incr_op to MINUS_EXPR. But the new interface
allows STEP to start out applying positively or negatively, and so
this code needs to cope with both cases.
Thanks,
Richard
next prev parent reply other threads:[~2023-05-11 5:14 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-04 13:25 juzhe.zhong
2023-05-05 23:41 ` 钟居哲
2023-05-09 12:59 ` Richard Sandiford
2023-05-09 13:27 ` juzhe.zhong
2023-05-09 14:34 ` 钟居哲
2023-05-07 15:19 ` Jeff Law
2023-05-07 21:54 ` 钟居哲
2023-05-09 10:52 ` juzhe.zhong
2023-05-08 5:35 ` Kewen.Lin
2023-05-08 6:27 ` juzhe.zhong
2023-05-08 7:55 ` Kewen.Lin
2023-05-08 8:25 ` juzhe.zhong
2023-05-10 16:45 ` Richard Sandiford
2023-05-10 21:00 ` 钟居哲
2023-05-10 21:28 ` Richard Sandiford
2023-05-10 22:51 ` 钟居哲
2023-05-11 4:50 ` Richard Sandiford
2023-05-11 5:14 ` juzhe.zhong [this message]
2023-05-11 10:11 ` juzhe.zhong
2023-05-11 11:04 ` Richard Sandiford
2023-05-11 11:21 ` juzhe.zhong
2023-05-11 11:29 ` Richard Sandiford
2023-05-11 12:08 ` juzhe.zhong
2023-05-11 12:42 ` Richard Sandiford
2023-05-11 23:12 ` 钟居哲
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=1F244094F9BCED03+20230511131407104447194@rivai.ai \
--to=juzhe.zhong@rivai.ai \
--cc=gcc-patches@gcc.gnu.org \
--cc=rguenther@suse.de \
--cc=richard.sandiford@arm.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).