public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dann at godzilla dot ics dot uci dot edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/26944]  New: -ftree-ch generates worse code
Date: Thu, 30 Mar 2006 16:15:00 -0000	[thread overview]
Message-ID: <bug-26944-1008@http.gcc.gnu.org/bugzilla/> (raw)

The loop from the code below is compiled to this when using gcc-4.1 -O2
.L5:
        movl    16(%ebp), %eax
        addl    %ecx, %eax
        addl    $1, %ecx
        movl    %edx, 20(%ebx,%eax,4)
        leal    (%edx,%ecx), %eax
        cmpl    %edi, %eax
        jle     .L5
but the code is much better when using gcc -fno-tree-ch -O2 
.L3:
        addl    $1, %ecx
        movl    %ebx, -4(%edx)
        addl    $4, %edx
        cmpl    %eax, %ecx
        jle     .L3
This is a regression as gcc-3.4.3 generates similar code. 

The code is from the Dhrystone as included in Unixbench.

The regression is quite important as embedded processor people still use
Dhrystone for benchmarking compiler/processor speed.

Its strange that tree-ch messes up, the loop is about as simple as loops can
get. 

typedef int One_Fifty;
typedef int Arr_1_Dim [50];
typedef int Arr_2_Dim [50] [50];
extern int Int_Glob;

void Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
     Arr_1_Dim Arr_1_Par_Ref;
     Arr_2_Dim Arr_2_Par_Ref;
     int Int_1_Par_Val;
     int Int_2_Par_Val;
{
  register One_Fifty Int_Index;
  register One_Fifty Int_Loc;

  Int_Loc = Int_1_Par_Val + 5;
  Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
  Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
  Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
  for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
    Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
  Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
  Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
  Int_Glob = 5;
}


Intel's compiler generates even tighter code:

..B1.7:                         # Preds ..B1.10 ..B1.7
        movl      %ebx, (%ecx,%edx,4)                           #20.5
        addl      $1, %edx                                      #19.55
        cmpl      %eax, %edx                                    #19.3
        jle       ..B1.7        # Prob 80%                      #19.3


-- 
           Summary: -ftree-ch generates worse code
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dann at godzilla dot ics dot uci dot edu
GCC target triplet: i686-pc-linux-gnu


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


             reply	other threads:[~2006-03-30 16:15 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-30 16:15 dann at godzilla dot ics dot uci dot edu [this message]
2006-03-30 16:25 ` [Bug tree-optimization/26944] [4.1/4.2 Regression] " rguenth at gcc dot gnu dot org
2006-03-30 16:43 ` dann at godzilla dot ics dot uci dot edu
2006-03-31 22:41   ` Daniel Berlin
2006-03-31 22:41 ` dberlin at dberlin dot org
2006-04-02  8:12 ` pinskia at gcc dot gnu dot org
2006-04-16 19:13 ` mmitchel at gcc dot gnu dot org
2006-05-02 17:38 ` steven at gcc dot gnu dot org
2006-05-03 18:55 ` dann at godzilla dot ics dot uci dot edu
2006-05-03 19:00   ` Andrew Pinski
2006-05-03 19:00 ` pinskia at physics dot uc dot edu
2006-05-03 21:33 ` steven at gcc dot gnu dot org
2006-05-03 21:53 ` dann at godzilla dot ics dot uci dot edu
2006-05-04 21:25 ` pinskia at gcc dot gnu dot org
2006-05-25  2:39 ` mmitchel at gcc dot gnu dot org
2007-02-14  9:10 ` [Bug tree-optimization/26944] [4.1/4.2/4.3 " mmitchel at gcc dot gnu dot org
2007-06-18  5:28 ` [Bug tree-optimization/26944] [4.1/4.2 " pinskia at gcc dot gnu dot org
2008-07-04 20:22 ` [Bug tree-optimization/26944] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-30 15:51 ` jsm28 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=bug-26944-1008@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).