From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10681 invoked by alias); 23 Apr 2003 12:56:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 10650 invoked by uid 71); 23 Apr 2003 12:56:00 -0000 Date: Wed, 23 Apr 2003 12:56:00 -0000 Message-ID: <20030423125600.10649.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Bruno Haible Subject: Re: optimization/6585: useless memory store instructions on x86 Reply-To: Bruno Haible X-SW-Source: 2003-04/txt/msg00963.txt.bz2 List-Id: The following reply was made to PR optimization/6585; it has been noted by GNATS. From: Bruno Haible To: bangerth@dealii.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Cc: Subject: Re: optimization/6585: useless memory store instructions on x86 Date: Wed, 23 Apr 2003 14:53:49 +0200 (CEST) > Bruno, I can verify your problem with 3.2, but I get > significantly better code with 3.2.2. Can you say a word > whether the new code satisfies you? No, the new code is somewhat better, but still exhibits three problems: - The dead store is still there. - The prologue still saves and restores an unused register. - The final reshuffling of registers before return is suboptimal. =========================== mul.c =============================== long long mul (long long a, long long b) { return a * b; } ================================================================= $ gcc -v Reading specs from /packages/gnu-inst-gcc/3.2.2/lib/gcc-lib/i686-pc-linux-gnu/3.2.2/specs Configured with: ../configure --prefix=/packages/gnu-inst-gcc/3.2.2 --enable-shared --enable-version-specific-runtime-libs --enable-nls --enable-threads=posix --enable-__cxa_atexit Thread model: posix gcc version 3.2.2 $ gcc -O6 -fomit-frame-pointer -S mul.c $ cat mul.s .file "mul.c" .text .p2align 4,,15 .globl mul .type mul,@function mul: subl $20, %esp movl 24(%esp), %eax a0 movl %ebx, 8(%esp) save %ebx movl 32(%esp), %ebx b0 movl %esi, 12(%esp) save %esi movl 36(%esp), %ecx b1 movl %edi, 16(%esp) save %edi USELESS! movl 16(%esp), %edi restore %edi USELESS! mull %ebx %edx:%eax := a0*b0 movl %edx, %esi movl %eax, (%esp) movl 24(%esp), %eax a0 movl %edx, 4(%esp) USELESS! imull %ecx, %eax a0*b1 addl %eax, %esi movl 28(%esp), %eax a1 imull %eax, %ebx a1*b0 leal (%ebx,%esi), %eax movl 12(%esp), %esi movl 8(%esp), %ebx movl %eax, 4(%esp) ! Could be simplified to 2 instructions: movl (%esp), %eax ! movl %eax, %edx movl 4(%esp), %edx ! movl (%esp), %eax addl $20, %esp ret .Lfe1: .size mul,.Lfe1-mul .ident "GCC: (GNU) 3.2.2"