public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: Andrew Thomas Pinski <pinskia@gmail.com> To: "gcc-bugzilla@gcc.gnu.org" <gcc-bugzilla@gcc.gnu.org> Cc: "gcc-bugs@gcc.gnu.org" <gcc-bugs@gcc.gnu.org> Subject: Re: [Bug inline-asm/37562] New: [4.2] -funroll-loops destroys inline asm code von powerpc Date: Wed, 17 Sep 2008 16:52:00 -0000 [thread overview] Message-ID: <24486F72-B8DD-4640-81BB-4F51D18302C3@gmail.com> (raw) In-Reply-To: <bug-37562-15404@http.gcc.gnu.org/bugzilla/> Sent from my iPhone On Sep 17, 2008, at 8:42 AM, "rbuergel at web dot de" <gcc-bugzilla@gcc.gnu.org > wrote: > typedef unsigned int UInt32; > typedef unsigned char UInt8; > > struct Data > { > UInt8 data[16]; > > const UInt8* getData() const > { > return data + 4; > } > }; > > struct Value { > UInt32 value; > static void update (Value& signal, const Data& source, UInt32 > startBit); > }; > > void Value::update(Value& signal, const Data& source, UInt32 > startByte) > { > UInt32& value = signal.value; > const UInt8* data = source.getData(); > asm( "lwbrx %0,%1,%2;\n":"=r"(value): "r"(data), "r"(startByte), > "m" (*(data > + startByte)) ); > } The second constraint should be using "b" instead of "r" as b says don't use r0. > > > generated for gcc-4.2.4 on powerpc: > 00000000 <_ZN5Value6updateERS_RK4Dataj>: > 0: 38 04 00 04 addi r0,r4,4 > 4: 7c 80 2c 2c lwbrx r4,0,r5 > 8: 90 83 00 00 stw r4,0(r3) > c: 4e 80 00 20 blr > > the correct version without -funroll-loops reads: > 00000000 <_ZN5Value6updateERS_RK4Dataj>: > 0: 38 84 00 04 addi r4,r4,4 > 4: 7c 84 2c 2c lwbrx r4,r4,r5 > 8: 90 83 00 00 stw r4,0(r3) > c: 4e 80 00 20 blr > > > lwbrx sums the contents of r4 and r5 and accesses this address, > swaps it's > value and stores it again in r4. The incorrect version accesses an > invalid > address, which leads to a segmentation fault. > > this is corrected at least with gcc-4.3.1, there i couldn't > reproduce the > behaviour. > > > -- > Summary: [4.2] -funroll-loops destroys inline asm code von > powerpc > Product: gcc > Version: 4.2.4 > Status: UNCONFIRMED > Severity: normal > Priority: P3 > Component: inline-asm > AssignedTo: unassigned at gcc dot gnu dot org > ReportedBy: rbuergel at web dot de > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37562 >
next prev parent reply other threads:[~2008-09-17 16:52 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2008-09-17 15:43 rbuergel at web dot de 2008-09-17 15:45 ` [Bug inline-asm/37562] " rbuergel at web dot de 2008-09-17 16:52 ` Andrew Thomas Pinski [this message] 2008-09-17 16:53 ` [Bug inline-asm/37562] [4.2] -funroll-loops destroys inline asm code for powerpc pinskia at gmail dot com 2008-09-17 18:47 ` rbuergel at web dot de 2008-09-17 18:51 ` pinskia at gcc dot gnu dot org 2008-09-17 18:58 ` rbuergel at web dot de 2008-09-17 19:08 ` pinskia at gcc dot gnu dot org
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=24486F72-B8DD-4640-81BB-4F51D18302C3@gmail.com \ --to=pinskia@gmail.com \ --cc=gcc-bugs@gcc.gnu.org \ --cc=gcc-bugzilla@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: linkBe 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).