From: Paolo Bonzini <pbonzini@redhat.com>
To: "Radim Krčmář" <rkrcmar@redhat.com>, qemu-devel@nongnu.org
Cc: Michael Walle <michael@walle.cc>
Subject: Re: [Qemu-devel] [PATCH 2/2] milkymist-pfpu: fix GCC 5.0.0 aggressive-loop-optimizations warning
Date: Fri, 20 Feb 2015 15:36:18 +0100 [thread overview]
Message-ID: <54E74662.5090203@redhat.com> (raw)
In-Reply-To: <1424441905-5735-3-git-send-email-rkrcmar@redhat.com>
On 20/02/2015 15:18, Radim Krčmář wrote:
> man gcc:
> Warn if in a loop with constant number of iterations the compiler
> detects undefined behavior in some statement during one or more of
> the iterations.
>
> Refactored the code a bit to avoid the GCC warning, in an objectionable
> way,
> hw/misc/milkymist-pfpu.c: In function ‘pfpu_write’:
> hw/misc/milkymist-pfpu.c:365:20: error: loop exit may only be reached after undefined behavior [-Werror=aggressive-loop-optimizations]
> if (i++ >= MICROCODE_WORDS) {
> ^
> hw/misc/milkymist-pfpu.c:167:14: note: possible undefined statement is here
> uint32_t insn = s->microcode[pc];
> ^
>
> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> ---
> hw/misc/milkymist-pfpu.c | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/hw/misc/milkymist-pfpu.c b/hw/misc/milkymist-pfpu.c
> index 609f33f9cd14..133f5b8c5153 100644
> --- a/hw/misc/milkymist-pfpu.c
> +++ b/hw/misc/milkymist-pfpu.c
> @@ -164,6 +164,13 @@ output_queue_advance(MilkymistPFPUState *s)
> static int pfpu_decode_insn(MilkymistPFPUState *s)
> {
> uint32_t pc = s->regs[R_PC];
> +
> + if (pc > MICROCODE_WORDS) {
> + error_report("milkymist_pfpu: too many instructions "
> + "executed in microcode. No VECTOUT?");
> + return 0;
> + }
> +
> uint32_t insn = s->microcode[pc];
> uint32_t reg_a = (insn >> 18) & 0x7f;
> uint32_t reg_b = (insn >> 11) & 0x7f;
> @@ -348,7 +355,6 @@ static int pfpu_decode_insn(MilkymistPFPUState *s)
> static void pfpu_start(MilkymistPFPUState *s)
> {
> int x, y;
> - int i;
>
> for (y = 0; y <= s->regs[R_VMESHLAST]; y++) {
> for (x = 0; x <= s->regs[R_HMESHLAST]; x++) {
> @@ -359,15 +365,7 @@ static void pfpu_start(MilkymistPFPUState *s)
> s->gp_regs[GPR_Y] = y;
>
> /* run microcode on this position */
> - i = 0;
> - while (pfpu_decode_insn(s)) {
> - /* decode at most MICROCODE_WORDS instructions */
> - if (i++ >= MICROCODE_WORDS) {
Isn't the fix just to say "++i" instead of "i++"?
Paolo
> - error_report("milkymist_pfpu: too many instructions "
> - "executed in microcode. No VECTOUT?");
> - break;
> - }
> - }
> + while (pfpu_decode_insn(s));
>
> /* reset pc for next run */
> s->regs[R_PC] = 0;
>
next prev parent reply other threads:[~2015-02-20 14:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-20 14:18 [Qemu-devel] [PATCH 0/2] Fix GCC 5.0.0 build errors Radim Krčmář
2015-02-20 14:18 ` [Qemu-devel] [PATCH 1/2] fix GCC 5.0.0 logical-not-parentheses warnings Radim Krčmář
2015-02-20 14:38 ` Paolo Bonzini
2015-02-20 15:43 ` Radim Krčmář
2015-02-20 14:18 ` [Qemu-devel] [PATCH 2/2] milkymist-pfpu: fix GCC 5.0.0 aggressive-loop-optimizations warning Radim Krčmář
2015-02-20 14:24 ` Radim Krčmář
2015-02-20 14:36 ` Paolo Bonzini [this message]
2015-02-20 14:52 ` Michael Walle
2015-02-20 14:55 ` Paolo Bonzini
2015-02-20 15:48 ` Radim Krčmář
2015-02-20 14:40 ` Peter Maydell
2015-02-20 15:37 ` Radim Krčmář
2015-02-20 16:10 ` Michael Walle
-- strict thread matches above, loose matches on Subject: below --
2015-02-20 16:06 [Qemu-devel] [PATCH 0/2] Fix GCC 5.0.0 build errors Radim Krčmář
2015-02-20 16:06 ` [Qemu-devel] [PATCH 2/2] milkymist-pfpu: fix GCC 5.0.0 aggressive-loop-optimizations warning Radim Krčmář
2015-02-23 17:32 ` Michael Walle
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=54E74662.5090203@redhat.com \
--to=pbonzini@redhat.com \
--cc=michael@walle.cc \
--cc=qemu-devel@nongnu.org \
--cc=rkrcmar@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.