Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(867)

Issue 7066055: code review 7066055: cmd/6c: Improve peep hole optimization of rotate and sh... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 6 months ago by mdempsky
Modified:
12 years, 6 months ago
Reviewers:
CC:
rsc, minux1, dave_cheney.net, nigeltao, golang-dev
Visibility:
Public.

Description

cmd/6c: Improve peep hole optimization of rotate and shift instructions. Update issue 4629. $ cat shift2.c unsigned int shift(unsigned int x, unsigned int y) { x = (x << 3); y = (y << 5); x = (x << 7); y = (y << 9); return x ^ y; } ## BEFORE $ go tool 6c -S shift2.c (shift2.c:2) TEXT shift+0(SB),$0-8 (shift2.c:4) MOVL x+0(FP),!!AX (shift2.c:4) SALL $3,!!AX (shift2.c:4) MOVL AX,!!DX (shift2.c:5) MOVL y+4(FP),!!AX (shift2.c:5) SALL $5,!!AX (shift2.c:5) MOVL AX,!!CX (shift2.c:6) MOVL DX,!!AX (shift2.c:6) SALL $7,!!AX (shift2.c:6) MOVL AX,!!DX (shift2.c:7) MOVL CX,!!AX (shift2.c:7) SALL $9,!!AX (shift2.c:7) MOVL AX,!!CX (shift2.c:8) MOVL DX,!!AX (shift2.c:8) XORL CX,!!AX (shift2.c:8) RET ,!! (shift2.c:8) RET ,!! (shift2.c:8) END ,!! ## AFTER $ go tool 6c -S shift2.c (shift2.c:2) TEXT shift+0(SB),$0-8 (shift2.c:4) MOVL x+0(FP),!!AX (shift2.c:4) SALL $3,!!AX (shift2.c:5) MOVL y+4(FP),!!CX (shift2.c:5) SALL $5,!!CX (shift2.c:6) SALL $7,!!AX (shift2.c:7) SALL $9,!!CX (shift2.c:8) XORL CX,!!AX (shift2.c:8) RET ,!! (shift2.c:8) RET ,!! (shift2.c:8) END ,!!

Patch Set 1 #

Patch Set 2 : diff -r 8906cf341c9b https://code.google.com/p/go #

Patch Set 3 : diff -r afa30db15b70 https://code.google.com/p/go #

Total comments: 3

Patch Set 4 : diff -r afa30db15b70 https://code.google.com/p/go #

Patch Set 5 : diff -r fc9545bf5a1f https://code.google.com/p/go #

Unified diffs Side-by-side diffs Delta from patch set Stats (+22 lines, -14 lines) Patch
M src/cmd/6c/peep.c View 1 2 3 3 chunks +19 lines, -14 lines 0 comments Download
M src/cmd/6g/peep.c View 1 2 3 3 chunks +3 lines, -0 lines 0 comments Download

Messages

Total messages: 16
mdempsky
Hello rsc@golang.org (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go
12 years, 6 months ago (2013-01-09 21:06:44 UTC) #1
mdempsky
https://codereview.appspot.com/7066055/diff/1003/src/cmd/6c/peep.c File src/cmd/6c/peep.c (right): https://codereview.appspot.com/7066055/diff/1003/src/cmd/6c/peep.c#newcode333 src/cmd/6c/peep.c:333: This matches 6g/peep.c like you asked, but is it ...
12 years, 6 months ago (2013-01-09 21:08:09 UTC) #2
minux1
any before/after comparisons of '6c -S'? (please add to the description)
12 years, 6 months ago (2013-01-09 21:11:02 UTC) #3
mdempsky
On 2013/01/09 21:11:02, minux wrote: > any before/after comparisons of '6c -S'? > (please add ...
12 years, 6 months ago (2013-01-09 21:16:29 UTC) #4
mdempsky
Er, I should point out the "BEFORE" there is with 7069056 applied. The status quo ...
12 years, 6 months ago (2013-01-09 21:18:29 UTC) #5
mdempsky
Oh right, it helps shifts too. :) Updated the description to provide an example. https://codereview.appspot.com/7066055/diff/1003/src/cmd/6c/peep.c ...
12 years, 6 months ago (2013-01-09 21:24:17 UTC) #6
rsc
LGTM Could you add an explicit return 0; to the IMULW case in both 6c ...
12 years, 6 months ago (2013-01-09 21:57:49 UTC) #7
dave_cheney.net
Thoughts about doing this for 8c (if affected) ? On Thu, Jan 10, 2013 at ...
12 years, 6 months ago (2013-01-09 22:00:54 UTC) #8
minux1
On Thu, Jan 10, 2013 at 6:00 AM, Dave Cheney <dave@cheney.net> wrote: > Thoughts about ...
12 years, 6 months ago (2013-01-09 22:08:17 UTC) #9
mdempsky
Hello rsc@golang.org, minux.ma@gmail.com, dave@cheney.net (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 6 months ago (2013-01-09 22:45:49 UTC) #10
mdempsky
On 2013/01/09 21:57:49, rsc wrote: > Could you add an explicit return 0; to the ...
12 years, 6 months ago (2013-01-09 22:48:35 UTC) #11
nigeltao
In the CL description, s/Related to issue 4629./Update issue 4629./ and leave a blank line ...
12 years, 6 months ago (2013-01-10 00:58:44 UTC) #12
mdempsky
On 2013/01/10 00:58:44, nigeltao wrote: > In the CL description, s/Related to issue 4629./Update issue ...
12 years, 6 months ago (2013-01-10 01:00:40 UTC) #13
mdempsky
Ping?
12 years, 6 months ago (2013-01-18 20:32:34 UTC) #14
rsc
LGTM
12 years, 6 months ago (2013-01-18 21:32:42 UTC) #15
rsc
12 years, 6 months ago (2013-01-18 21:33:35 UTC) #16
*** Submitted as https://code.google.com/p/go/source/detail?r=8d1bf4554310 ***

cmd/6c: Improve peep hole optimization of rotate and shift instructions.

Update issue 4629.

$ cat shift2.c
unsigned int
shift(unsigned int x, unsigned int y)
{
        x = (x << 3);
        y = (y << 5);
        x = (x << 7);
        y = (y << 9);
        return x ^ y;
}

## BEFORE
$ go tool 6c -S shift2.c
(shift2.c:2)	TEXT	shift+0(SB),$0-8
(shift2.c:4)	MOVL	x+0(FP),!!AX
(shift2.c:4)	SALL	$3,!!AX
(shift2.c:4)	MOVL	AX,!!DX
(shift2.c:5)	MOVL	y+4(FP),!!AX
(shift2.c:5)	SALL	$5,!!AX
(shift2.c:5)	MOVL	AX,!!CX
(shift2.c:6)	MOVL	DX,!!AX
(shift2.c:6)	SALL	$7,!!AX
(shift2.c:6)	MOVL	AX,!!DX
(shift2.c:7)	MOVL	CX,!!AX
(shift2.c:7)	SALL	$9,!!AX
(shift2.c:7)	MOVL	AX,!!CX
(shift2.c:8)	MOVL	DX,!!AX
(shift2.c:8)	XORL	CX,!!AX
(shift2.c:8)	RET	,!!
(shift2.c:8)	RET	,!!
(shift2.c:8)	END	,!!

## AFTER
$ go tool 6c -S shift2.c
(shift2.c:2)	TEXT	shift+0(SB),$0-8
(shift2.c:4)	MOVL	x+0(FP),!!AX
(shift2.c:4)	SALL	$3,!!AX
(shift2.c:5)	MOVL	y+4(FP),!!CX
(shift2.c:5)	SALL	$5,!!CX
(shift2.c:6)	SALL	$7,!!AX
(shift2.c:7)	SALL	$9,!!CX
(shift2.c:8)	XORL	CX,!!AX
(shift2.c:8)	RET	,!!
(shift2.c:8)	RET	,!!
(shift2.c:8)	END	,!!

R=rsc, minux.ma, dave, nigeltao
CC=golang-dev
https://codereview.appspot.com/7066055

Committer: Russ Cox <rsc@golang.org>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b