From mint-bounce@lists.fishpool.fi Wed Jun 9 15:04:37 2010 Message-ID: <4C0FE450.4050701@freesbee.fr> Date: Wed, 09 Jun 2010 20:58:24 +0200 From: =?ISO-8859-1?Q?Vincent_Rivi=E8re?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: mint@lists.fishpool.fi Subject: Re: [MiNT] Optimisation bug in gcc 4 ? References: <20100609194827.0a54c39a.mandin.patrice@orange.fr> In-Reply-To: <20100609194827.0a54c39a.mandin.patrice@orange.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-ecartis-version: Ecartis v1.0.0 Sender: mint-bounce@lists.fishpool.fi Errors-to: mint-bounce@lists.fishpool.fi X-original-sender: vincent.riviere@freesbee.fr Precedence: bulk List-help: List-unsubscribe: List-Id: X-List-ID: List-subscribe: List-owner: List-post: Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.sparemint.org id o59J4bMr027808 Patrice Mandin wrote: > with gcc 4.4.2 (starting at -O1 level), it assumes the field has a > constant value, optimizes the test by removing it, and the code that > follows, thus also wiping out entirely the function myvidix_func from > the generated assembly code Sorry, I can't reproduce your bug, either with gcc 4.4.2 or 4.5.0 (with my own patches). Look at the definition of trap_14_wl() in /usr/.../include/mint/osbind.h: #define trap_14_wllw(n, a, b, c) \ __extension__ \ ({ \ register long retvalue __asm__("d0"); \ long _a = (long) (a); \ long _b = (long) (b); \ short _c = (short)(c); \ \ __asm__ volatile \ ( \ "movw %4,sp@-\n\t" \ "movl %3,sp@-\n\t" \ "movl %2,sp@-\n\t" \ "movw %1,sp@-\n\t" \ "trap #14\n\t" \ "lea sp@(12),sp" \ : "=r"(retvalue) /* outputs */ \ : "g"(n), "r"(_a), "r"(_b), "r"(_c) /* inputs */ \ : __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2" /* clobbered regs */ \ AND_MEMORY \ ); \ retvalue; \ }) The important word is "volatile" after __asm__. It prevents the assembler code block to be dropped if the compiler thinks it is useless. If I remove the volatile keyword the code disappears with some tests. But when volatile is present, it always work. There is something special on your system, I can't understand why it fails. Except if you have messed your osbind.h file, which is probably not the case. Someone else should try the testcase. -- Vincent Rivière