Bug 7067 - -Os with -mcpu=powerpc optimizes for speed (?) instead of space
Summary: -Os with -mcpu=powerpc optimizes for speed (?) instead of space
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.1
: P3 normal
Target Milestone: ---
Assignee: David Edelsohn
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2002-06-18 08:06 UTC by fshvaige
Modified: 2003-07-25 17:33 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fshvaige 2002-06-18 08:06:13 UTC
File test4.c:
unsigned f (unsigned v) {
  return v * 10;
}

Command line:
ppc-eabi-gcc -S -Os test4.c

Produced code (right, space optimized):
f:
  mulli 3,3,10
  blr

Command line:
ppc-eabi-gcc -S -Os -mcpu=powerpc test4.c

Produced code (wrong, probably speed optimized ?):
f:
  mr 0,3
  slwi 3,3,2
  add 3,3,0
  slwi 3,3,1
  blr

Note: instruction "mulli" present in powerpc and even used by the same compiler and same command line for the very alike function, so problem is somewhere in optimization.

File test4a.c:
unsigned f (unsigned v) {
  return v * 11;
}

Command line:
ppc-eabi-gcc -S -Os -mcpu=powerpc test4a.c

Produced code (right):
f:
  mulli 3,3,11
  blr

Release:
3.1 20020510 (prerelease)

Environment:
../gcc-3.1/configure --with-gcc-version-trigger=/home/install/gcc-3.1/gcc/version.c --host=i686-pc-linux-gnu --with-newlib --enable-target-optspace --target=ppc-eabi --prefix=/home/crossGCC/ppc-eabi --with-local-prefix=/home/crossGCC/ppc-eabi --program-prefix=ppc-eabi- --enable-languages=c,c++ -v --norecursion

How-To-Repeat:
ppc-eabi-gcc -S -Os test4.c
ppc-eabi-gcc -S -Os -mcpu=powerpc test4.c
ppc-eabi-gcc -S -Os -mcpu=powerpc test4a.c
Comment 1 David Edelsohn 2002-08-01 15:24:48 UTC
Responsible-Changed-From-To: unassigned->dje
Responsible-Changed-Why: PowerPC
Comment 2 David Edelsohn 2002-08-01 15:24:48 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Should optimize_size affect RTX_COSTS(MULT)?
Comment 3 David Edelsohn 2002-08-02 09:26:30 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Addressed in GCC 3.3