This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug other/17108] New: Missed opportunity for strength reduction


Description:
A non-optimal code sequence is illustraded.    Duplicate using gcc 3.5 and
command line:

gcc -O3 -m64 -c test.c


Testcase:
void foo(float *data, float d) {
   long i;

   for (i = 0; i < 8; i++)
      data[i] = d;
}

Assembly:
Code generated by gcc 3.5:

.foo:
      li 0,8
      li 9,0
      mtctr 0
.L2:
      sldi 0,9,2
      addi 9,9,1
      stfsx 1,3,0
      bdnz .L2
      blr

We can eliminate the multiply(shift) as well as the increment of "i" and
use
a store with update form to simplify the loop to this:

.foo:
      ai 3,3,-4
      li 0,8
      mtctr 0
.L2:
      stfsu 1,3,4
      bdnz .L2
      blr




-- 
           Summary: Missed opportunity for strength reduction
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P1
         Component: other
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: steinmtz at us dot ibm dot com
                CC: gcc-bugs at gcc dot gnu dot org,steinmtz at us dot ibm
                    dot com
 GCC build triplet: powerpc64-linux
  GCC host triplet: powerpc64-linux
GCC target triplet: powerpc64-linux


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]