Return-Path: Delivered-To: apmail-stdcxx-issues-archive@locus.apache.org Received: (qmail 47054 invoked from network); 2 Jun 2008 18:22:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jun 2008 18:22:08 -0000 Received: (qmail 89216 invoked by uid 500); 2 Jun 2008 18:22:10 -0000 Delivered-To: apmail-stdcxx-issues-archive@stdcxx.apache.org Received: (qmail 89193 invoked by uid 500); 2 Jun 2008 18:22:10 -0000 Mailing-List: contact issues-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list issues@stdcxx.apache.org Received: (qmail 89174 invoked by uid 99); 2 Jun 2008 18:22:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jun 2008 11:22:10 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jun 2008 18:21:23 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 10446234C126 for ; Mon, 2 Jun 2008 11:21:45 -0700 (PDT) Message-ID: <2077201427.1212430905052.JavaMail.jira@brutus> Date: Mon, 2 Jun 2008 11:21:45 -0700 (PDT) From: "Martin Sebor (JIRA)" To: issues@stdcxx.apache.org Subject: [jira] Updated: (STDCXX-335) std::min() suboptimal MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/STDCXX-335?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Martin Sebor updated STDCXX-335: -------------------------------- Severity: Inefficiency Remaining Estimate: 4h Original Estimate: 4h Estimated effort to assess the issue by reviewing object code generated by popular compilers and decide on a solution (if any). > std::min() suboptimal > --------------------- > > Key: STDCXX-335 > URL: https://issues.apache.org/jira/browse/STDCXX-335 > Project: C++ Standard Library > Issue Type: Bug > Components: 25. Algorithms > Affects Versions: 4.1.3 > Environment: gcc 3.2.3, x86 Linux > Reporter: Mark Brown > Fix For: 4.3 > > Original Estimate: 4h > Remaining Estimate: 4h > > I don't know if it's the compiler that's generating worse code for the stdcxx version of min or if the function is not implemented as efficiently as it could be but the disassembly for the two functions below shows that my_min() is one instruction shorter than test_min(): > #include > int test_min (int x, int y) { return std::min (x, y); } > int my_min (int x, int y) { return x < y ? x : y; } > _Z8test_minii: > pushl %ebp > movl %esp, %ebp > movl 12(%ebp), %eax > cmpl %eax, 8(%ebp) > jg .L2 > leal 8(%ebp), %eax <<< extra load? > .L4: > movl (%eax), %eax > leave > ret > _Z6my_minii: > pushl %ebp > movl %esp, %ebp > movl 12(%ebp), %eax > cmpl 8(%ebp), %eax > jle .L6 > movl 8(%ebp), %eax > .L6: > leave > ret -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.