Bug 10588 - [PPC] i==0||j==0 should use cntlzw and srawi
Summary: [PPC] i==0||j==0 should use cntlzw and srawi
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.4.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks: spec 15524
  Show dependency treegraph
 
Reported: 2003-05-01 21:06 UTC by Andrew Pinski
Modified: 2015-12-16 20:22 UTC (History)
4 users (show)

See Also:
Host:
Target: powerpc-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-10-22 23:04:59


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2003-05-01 21:06:00 UTC
compile:
int h(int i, int j)
{
 return i==0||j==0;
}
you get currently:
_h:
        subfic r0,r3,0
        adde r2,r0,r3
        subfic r0,r4,0
        adde r5,r0,r4
        or r3,r2,r5
        blr
I would like gcc to produce:
_h:
        cntlzw r5,r3
        cntlzw r2,r4
        or r0,r2,r5
        srwi r3,r0,5
        blr
Which is smaller and faster.

Note this will speed up gcc.

Release:
all (3.4)

Environment:
ppc-darwin6.5

How-To-Repeat:
see description.
Comment 1 Andrew Pinski 2003-05-01 21:06:00 UTC
Fix:
When converting the trees into rtl do this translation if the backend requests it.  I tried to do it in combine but this did not work because it was replacing two rtls with two, so it rejected it.
Comment 2 Andrew Pinski 2003-05-24 00:59:45 UTC
confirmed on mainline (20030523).
Comment 3 Andrew Pinski 2004-05-18 20:47:08 UTC
This improves PR15524.
Comment 4 Andrew Pinski 2004-05-22 04:10:14 UTC
I have a fix, testing it right now.
Comment 5 Andrew Pinski 2004-05-28 13:33:21 UTC
A RFC here: <http://gcc.gnu.org/ml/gcc-patches/2004-05/msg01818.html>.
Comment 6 Andrew Pinski 2005-05-04 04:28:19 UTC
I have not looked at this for a long time now.
Comment 7 CVS Commits 2005-06-08 14:46:24 UTC
Subject: Bug 10588

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	dje@gcc.gnu.org	2005-06-08 14:46:14

Modified files:
	gcc            : ChangeLog 
	gcc/config/rs6000: rs6000.md 

Log message:
	* config/rs6000/rs6000.md (call_indirect_nonlocal_aix32): Prefer
	CTR to LR.
	(call_indirect_nonlocal_aix64): Same.
	(call_value_indirect_nonlocal_aix32): Same.
	(call_value_indirect_nonlocal_aix64): Same.
	
	PR target/10588
	(eq): Use CLZ splitter for compare with zero.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9091&r2=2.9092
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.md.diff?cvsroot=gcc&r1=1.375&r2=1.376

Comment 8 Andrew Pinski 2005-06-08 15:46:53 UTC
On the mainline we get the following now:
_h:
        cmpwi cr7,r3,0
        li r3,1
        beqlr- cr7
        cntlzw r3,r4
        srwi r3,r3,5
        blr
Comment 9 Bill Schmidt 2015-12-16 20:17:04 UTC
David, looks like you fixed this long ago -- can this be closed?
Comment 10 David Edelsohn 2015-12-16 20:22:40 UTC
Fixed.