This is the mail archive of the gcc-patches@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]

[PATCH RS6000] peephole changing a move to itself with compare to a compare


This peephole changes `mr. rA, rA' to `cmp{w,d}i rA, 0' which is faster on
the power 4, note I think there is a deficiency in a generic part of
gcc's back-end but this was the fastest way and easiest way to fix it.


For an example:
typedef int Wtype;

Wtype
__absvsi2 (Wtype a)
{
  Wtype w = a;

  if (a < 0)
    w = -a;

  if (w < 0)
    abort ();

   return w;
}

produces:
mr. r3,r3
mflr r2
stw r2,8(r1)
stwu r1,-64(r1)
blt- cr0,L5
L3:
addi r1,r1,64
lwz r2,8(r1)
mtlr r2
blr
L5:
neg. r3,r3
bge+ cr0,L3
bl _abort
which contains a `mr. r3,r3', with the patch gcc produces:
cmpwi cr1,r3,0
mflr r2
stw r2,8(r1)
stwu r1,-64(r1)
blt- cr1,L5
L3:
addi r1,r1,64
lwz r4,8(r1)
mtlr r4
blr
L5:
neg. r3,r3
bge+ cr0,L3
bl _abort
Which is what really wanted (if you change the type Wtype to long long and compile for PPC64, the same thing happens).


ChangeLog:

2003-05-13 Andrew Pinski <pinskia@physics.uc.edu>

	* config/rs6000/rs6000.md: add two peepholes for
	changing `mr. rA,rA' to `cmp{w,d}i rA, 0', one
	for non PPC64 case and one for the PPC64 case.

Patch:

Attachment: temp.diff
Description: Binary data



Thanks,
Andrew Pinski



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