public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "avr at gjlay dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug inline-asm/37895] AVR inline assembly clobbers input value
Date: Sat, 12 Mar 2011 13:01:00 -0000	[thread overview]
Message-ID: <bug-37895-4-9nzfhX2jDT@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-37895-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37895

Georg-Johann Lay <avr at gjlay dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eric.weddington at atmel
                   |                            |dot com

--- Comment #2 from Georg-Johann Lay <avr at gjlay dot de> 2011-03-12 13:01:13 UTC ---
I can not confirm the problems for WinAVR-20071221 (gcc 4.2.2)

With the following function

int32_t test_mul (void)
{
    int32_t res = mul_16_8(0x1234, 0x56);
    return res;
}

Both the generated code and the result of the computation (400760 in that
specific case) are as expected.

Presumably there is an error in your code outside the snippet (which we aren't
allowed to see), maybe some signed/undigned clashes, promotion problems,
overflows, etc.

The code compiles with 
  -S -Os -mmcu=atmega88 -fverbose-asm
to

<asm>
test_mul:
/* prologue: frame size=0 */
/* prologue end (size=0) */
    ldi r24,lo8(4660)     ;  tmp43,
    ldi r25,hi8(4660)     ;  tmp43,
    ldi r18,lo8(86)     ;  tmp44,
    movw r20,r24     ; , tmp43
/* #APP */
    clr r24;     ;  res
    clr r25;     ;  res
    mul r20, r18;     ; , tmp44
    movw r22, r0;     ;  res
    mul r21, r18;     ; , tmp44
    add r23, r0;     ;  res
    adc r24, r1;     ;  res
    clr __zero_reg__

/* #NOAPP */
/* epilogue: frame size=0 */
    ret
</asm>
which is correct. gcc respects the early-clobber, i.e. the output operand
(r22-r25) does not overlap an input operand (r20-r21 and r18).

IMO this bug is invalid and can be closed.

Johann


  parent reply	other threads:[~2011-03-12 13:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-37895-4@http.gcc.gnu.org/bugzilla/>
2010-11-06 12:20 ` avr at gjlay dot de
2011-03-12 13:01 ` avr at gjlay dot de [this message]
2011-03-14 13:52 ` Rudolf.Leitgeb at gmx dot at
2011-03-14 14:14 ` eric.weddington at atmel dot com

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=bug-37895-4-9nzfhX2jDT@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).