From: Richard Sandiford <richard.sandiford@arm.com>
To: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 2/3] expmed: Fix possible use of NULL_RTX return value from emit_store_flag
Date: Wed, 22 Jul 2020 09:38:15 +0100 [thread overview]
Message-ID: <mpt365kueq0.fsf@arm.com> (raw)
In-Reply-To: <20200721182649.mrhv4mk2qgigs7tv@jozef-acer-manjaro> (Jozef Lawrynowicz's message of "Tue, 21 Jul 2020 19:26:49 +0100")
Jozef Lawrynowicz <jozef.l@mittosystems.com> writes:
> diff --git a/gcc/expmed.c b/gcc/expmed.c
> index e7c03fbf92c..d3a1735d39e 100644
> --- a/gcc/expmed.c
> +++ b/gcc/expmed.c
> @@ -4086,9 +4086,12 @@ expand_sdiv_pow2 (scalar_int_mode mode, rtx op0, HOST_WIDE_INT d)
> {
> temp = gen_reg_rtx (mode);
> temp = emit_store_flag (temp, LT, op0, const0_rtx, mode, 0, 1);
> - temp = expand_binop (mode, add_optab, temp, op0, NULL_RTX,
> - 0, OPTAB_LIB_WIDEN);
> - return expand_shift (RSHIFT_EXPR, mode, temp, logd, NULL_RTX, 0);
> + if (temp != NULL_RTX)
> + {
> + temp = expand_binop (mode, add_optab, temp, op0, NULL_RTX,
> + 0, OPTAB_LIB_WIDEN);
> + return expand_shift (RSHIFT_EXPR, mode, temp, logd, NULL_RTX, 0);
> + }
> }
>
> if (HAVE_conditional_move
> @@ -4122,17 +4125,20 @@ expand_sdiv_pow2 (scalar_int_mode mode, rtx op0, HOST_WIDE_INT d)
>
> temp = gen_reg_rtx (mode);
> temp = emit_store_flag (temp, LT, op0, const0_rtx, mode, 0, -1);
> - if (GET_MODE_BITSIZE (mode) >= BITS_PER_WORD
> - || shift_cost (optimize_insn_for_speed_p (), mode, ushift)
> - > COSTS_N_INSNS (1))
> - temp = expand_binop (mode, and_optab, temp, gen_int_mode (d - 1, mode),
> - NULL_RTX, 0, OPTAB_LIB_WIDEN);
> - else
> - temp = expand_shift (RSHIFT_EXPR, mode, temp,
> - ushift, NULL_RTX, 1);
> - temp = expand_binop (mode, add_optab, temp, op0, NULL_RTX,
> - 0, OPTAB_LIB_WIDEN);
> - return expand_shift (RSHIFT_EXPR, mode, temp, logd, NULL_RTX, 0);
> + if (temp != NULL_RTX)
> + {
> + if (GET_MODE_BITSIZE (mode) >= BITS_PER_WORD
> + || shift_cost (optimize_insn_for_speed_p (), mode, ushift)
> + > COSTS_N_INSNS (1))
> + temp = expand_binop (mode, and_optab, temp, gen_int_mode (d - 1, mode),
Long line.
OK otherwise, thanks. I guess these failed attempts will leave
a few unused temporary registers around (from the gen_reg_rtxes)
but it's going to be hard to avoid that in a clean way.
Richard
> + NULL_RTX, 0, OPTAB_LIB_WIDEN);
> + else
> + temp = expand_shift (RSHIFT_EXPR, mode, temp,
> + ushift, NULL_RTX, 1);
> + temp = expand_binop (mode, add_optab, temp, op0, NULL_RTX,
> + 0, OPTAB_LIB_WIDEN);
> + return expand_shift (RSHIFT_EXPR, mode, temp, logd, NULL_RTX, 0);
> + }
> }
>
> label = gen_label_rtx ();
next prev parent reply other threads:[~2020-07-22 8:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-21 18:17 [PATCH 0/3] MSP430: Improve code-generation for shift instructions Jozef Lawrynowicz
2020-07-21 18:24 ` [PATCH 1/3] expr: Allow scalar_int_mode target mode when converting a constant Jozef Lawrynowicz
2020-07-22 8:33 ` Richard Sandiford
2020-07-22 9:48 ` Jozef Lawrynowicz
2020-07-24 14:14 ` Richard Sandiford
2020-07-21 18:26 ` [PATCH 2/3] expmed: Fix possible use of NULL_RTX return value from emit_store_flag Jozef Lawrynowicz
2020-07-22 8:38 ` Richard Sandiford [this message]
2020-07-21 18:29 ` [PATCH 3/3] MSP430: Simplify and extend shift instruction patterns Jozef Lawrynowicz
2020-08-07 10:55 ` ping " Jozef Lawrynowicz
2020-08-25 19:16 ` Jeff Law
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=mpt365kueq0.fsf@arm.com \
--to=richard.sandiford@arm.com \
--cc=gcc-patches@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: 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).