[go] cmd/compile: optimize integer comparisons with 1/-1 on riscv64

16 views
Skip to first unread message

Michael Munday (Gerrit)

unread,
Sep 20, 2021, 4:47:43 PM9/20/21
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Michael Munday has uploaded this change for review.

View Change

cmd/compile: optimize integer comparisons with 1/-1 on riscv64

Some integer comparisons with 1 and -1 can be rewritten as comparisons
with 0. For example, x < 1 is equivalent to x <= 0. This is an
advantageous transformation on riscv64 because comparisons with zero
do not require a constant to be loaded into a register.

The new rules trigger approximately 800 times when building cmd and
std.

Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
---
M src/cmd/compile/internal/ssa/gen/RISCV64.rules
M src/cmd/compile/internal/ssa/rewriteRISCV64.go
M test/codegen/compare_and_branch.go
3 files changed, 116 insertions(+), 0 deletions(-)

diff --git a/src/cmd/compile/internal/ssa/gen/RISCV64.rules b/src/cmd/compile/internal/ssa/gen/RISCV64.rules
index 4290d1b..22fdc64 100644
--- a/src/cmd/compile/internal/ssa/gen/RISCV64.rules
+++ b/src/cmd/compile/internal/ssa/gen/RISCV64.rules
@@ -617,6 +617,18 @@
(BGE (MOVDconst [0]) cond yes no) => (BLEZ cond yes no)
(BGE cond (MOVDconst [0]) yes no) => (BGEZ cond yes no)

+// Convert signed comparison with one to comparison with zero.
+(BGE x (MOVDconst [1]) yes no) => (BGTZ x yes no)
+(BLT x (MOVDconst [1]) yes no) => (BLEZ x yes no)
+
+// Convert signed comparison with minus one to comparison with zero.
+(BGE (MOVDconst [-1]) x yes no) => (BLTZ x yes no)
+(BLT (MOVDconst [-1]) x yes no) => (BGEZ x yes no)
+
+// Convert unsigned comparison with one to comparison with zero.
+(BGEU x (MOVDconst [1]) yes no) => (BGTZ x yes no)
+(BLTU x (MOVDconst [1]) yes no) => (BEQZ x yes no)
+
// Store zero
(MOVBstore [off] {sym} ptr (MOVDconst [0]) mem) => (MOVBstorezero [off] {sym} ptr mem)
(MOVHstore [off] {sym} ptr (MOVDconst [0]) mem) => (MOVHstorezero [off] {sym} ptr mem)
diff --git a/src/cmd/compile/internal/ssa/rewriteRISCV64.go b/src/cmd/compile/internal/ssa/rewriteRISCV64.go
index f856a26..c283345 100644
--- a/src/cmd/compile/internal/ssa/rewriteRISCV64.go
+++ b/src/cmd/compile/internal/ssa/rewriteRISCV64.go
@@ -6364,6 +6364,40 @@
b.resetWithControl(BlockRISCV64BGEZ, cond)
return true
}
+ // match: (BGE x (MOVDconst [1]) yes no)
+ // result: (BGTZ x yes no)
+ for b.Controls[1].Op == OpRISCV64MOVDconst {
+ x := b.Controls[0]
+ v_1 := b.Controls[1]
+ if auxIntToInt64(v_1.AuxInt) != 1 {
+ break
+ }
+ b.resetWithControl(BlockRISCV64BGTZ, x)
+ return true
+ }
+ // match: (BGE (MOVDconst [-1]) x yes no)
+ // result: (BLTZ x yes no)
+ for b.Controls[0].Op == OpRISCV64MOVDconst {
+ v_0 := b.Controls[0]
+ if auxIntToInt64(v_0.AuxInt) != -1 {
+ break
+ }
+ x := b.Controls[1]
+ b.resetWithControl(BlockRISCV64BLTZ, x)
+ return true
+ }
+ case BlockRISCV64BGEU:
+ // match: (BGEU x (MOVDconst [1]) yes no)
+ // result: (BGTZ x yes no)
+ for b.Controls[1].Op == OpRISCV64MOVDconst {
+ x := b.Controls[0]
+ v_1 := b.Controls[1]
+ if auxIntToInt64(v_1.AuxInt) != 1 {
+ break
+ }
+ b.resetWithControl(BlockRISCV64BGTZ, x)
+ return true
+ }
case BlockRISCV64BLT:
// match: (BLT (MOVDconst [0]) cond yes no)
// result: (BGTZ cond yes no)
@@ -6387,6 +6421,40 @@
b.resetWithControl(BlockRISCV64BLTZ, cond)
return true
}
+ // match: (BLT x (MOVDconst [1]) yes no)
+ // result: (BLEZ x yes no)
+ for b.Controls[1].Op == OpRISCV64MOVDconst {
+ x := b.Controls[0]
+ v_1 := b.Controls[1]
+ if auxIntToInt64(v_1.AuxInt) != 1 {
+ break
+ }
+ b.resetWithControl(BlockRISCV64BLEZ, x)
+ return true
+ }
+ // match: (BLT (MOVDconst [-1]) x yes no)
+ // result: (BGEZ x yes no)
+ for b.Controls[0].Op == OpRISCV64MOVDconst {
+ v_0 := b.Controls[0]
+ if auxIntToInt64(v_0.AuxInt) != -1 {
+ break
+ }
+ x := b.Controls[1]
+ b.resetWithControl(BlockRISCV64BGEZ, x)
+ return true
+ }
+ case BlockRISCV64BLTU:
+ // match: (BLTU x (MOVDconst [1]) yes no)
+ // result: (BEQZ x yes no)
+ for b.Controls[1].Op == OpRISCV64MOVDconst {
+ x := b.Controls[0]
+ v_1 := b.Controls[1]
+ if auxIntToInt64(v_1.AuxInt) != 1 {
+ break
+ }
+ b.resetWithControl(BlockRISCV64BEQZ, x)
+ return true
+ }
case BlockRISCV64BNE:
// match: (BNE (MOVDconst [0]) cond yes no)
// result: (BNEZ cond yes no)
diff --git a/test/codegen/compare_and_branch.go b/test/codegen/compare_and_branch.go
index f751506..d45902f 100644
--- a/test/codegen/compare_and_branch.go
+++ b/test/codegen/compare_and_branch.go
@@ -204,3 +204,39 @@
dummy()
}
}
+
+// Signed 64-bit comparison with 1/-1 to comparison with 0.
+func si64x0(x chan int64) {
+ // riscv64:"BGTZ"
+ for <-x >= 1 {
+ dummy()
+ }
+
+ // riscv64:"BLEZ"
+ for <-x < 1 {
+ dummy()
+ }
+
+ // riscv64:"BLTZ"
+ for <-x <= -1 {
+ dummy()
+ }
+
+ // riscv64:"BGEZ"
+ for <-x > -1 {
+ dummy()
+ }
+}
+
+// Unsigned 64-bit comparison with 1 to comparison with 0.
+func ui64x0(x chan uint64) {
+ // riscv64:"BGTZ"
+ for <-x >= 1 {
+ dummy()
+ }
+
+ // riscv64:"BEQZ"
+ for <-x < 1 {
+ dummy()
+ }
+}

To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
Gerrit-Change-Number: 350831
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
Gerrit-MessageType: newchange

Michael Munday (Gerrit)

unread,
Sep 20, 2021, 5:05:43 PM9/20/21
to goph...@pubsubhelper.golang.org, Keith Randall, Josh Bleecher Snyder, Martin Möhrmann, Go Bot, golang-co...@googlegroups.com

Michael Munday removed Keith Randall from this change.

View Change

To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
Gerrit-Change-Number: 350831
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
Gerrit-CC: Go Bot <go...@golang.org>
Gerrit-CC: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-CC: Martin Möhrmann <moeh...@google.com>
Gerrit-MessageType: deleteReviewer

Michael Munday (Gerrit)

unread,
Sep 20, 2021, 5:05:44 PM9/20/21
to goph...@pubsubhelper.golang.org, Josh Bleecher Snyder, Martin Möhrmann, Go Bot, golang-co...@googlegroups.com

Michael Munday removed Josh Bleecher Snyder from this change.

View Change

To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
Gerrit-Change-Number: 350831
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
Gerrit-CC: Go Bot <go...@golang.org>

Michael Munday (Gerrit)

unread,
Sep 20, 2021, 5:05:47 PM9/20/21
to goph...@pubsubhelper.golang.org, Martin Möhrmann, Go Bot, golang-co...@googlegroups.com

Michael Munday removed Martin Möhrmann from this change.

View Change

To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
Gerrit-Change-Number: 350831
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
Gerrit-CC: Go Bot <go...@golang.org>
Gerrit-MessageType: deleteReviewer

Michael Munday (Gerrit)

unread,
Sep 20, 2021, 5:05:50 PM9/20/21
to goph...@pubsubhelper.golang.org, Go Bot, golang-co...@googlegroups.com

Michael Munday removed Go Bot from this change.

View Change

To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
Gerrit-Change-Number: 350831
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
Gerrit-MessageType: deleteReviewer

Michael Munday (Gerrit)

unread,
Sep 20, 2021, 5:11:38 PM9/20/21
to goph...@pubsubhelper.golang.org, Keith Randall, Josh Bleecher Snyder, Martin Möhrmann, Go Bot, golang-co...@googlegroups.com

Michael Munday removed Keith Randall from this change.

View Change

To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
Gerrit-Change-Number: 350831
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
Gerrit-CC: Go Bot <go...@golang.org>
Gerrit-CC: Josh Bleecher Snyder <josh...@gmail.com>

Michael Munday (Gerrit)

unread,
Sep 20, 2021, 5:11:39 PM9/20/21
to goph...@pubsubhelper.golang.org, Josh Bleecher Snyder, Martin Möhrmann, Go Bot, golang-co...@googlegroups.com

Michael Munday removed Josh Bleecher Snyder from this change.

View Change

To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
Gerrit-Change-Number: 350831
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
Gerrit-CC: Go Bot <go...@golang.org>

Michael Munday (Gerrit)

unread,
Sep 20, 2021, 5:11:43 PM9/20/21
to goph...@pubsubhelper.golang.org, Martin Möhrmann, Go Bot, golang-co...@googlegroups.com

Michael Munday removed Martin Möhrmann from this change.

View Change

To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
Gerrit-Change-Number: 350831
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
Gerrit-CC: Go Bot <go...@golang.org>
Gerrit-MessageType: deleteReviewer

Michael Munday (Gerrit)

unread,
Sep 20, 2021, 5:12:13 PM9/20/21
to goph...@pubsubhelper.golang.org, Go Bot, golang-co...@googlegroups.com

Patch set 1:Run-TryBot +1Trust +1

View Change

1 comment:

To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
Gerrit-Change-Number: 350831
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
Gerrit-CC: Go Bot <go...@golang.org>
Gerrit-Comment-Date: Mon, 20 Sep 2021 21:12:08 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Keith Randall (Gerrit)

unread,
Sep 20, 2021, 5:30:21 PM9/20/21
to Michael Munday, goph...@pubsubhelper.golang.org, Keith Randall, Go Bot, golang-co...@googlegroups.com

Attention is currently required from: Michael Munday.

View Change

1 comment:

  • Patchset:

    • Patch Set #1:

      There was another similar CL that went in recently, CL 346050. Is this related to / redundant to / ... that one?

      It works on a generic level, which might also be worth doing here, as maybe many architectures would benefit (and none would be made worse, I think).

To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
Gerrit-Change-Number: 350831
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
Gerrit-CC: Go Bot <go...@golang.org>
Gerrit-CC: Keith Randall <k...@golang.org>
Gerrit-Attention: Michael Munday <mike....@lowrisc.org>
Gerrit-Comment-Date: Mon, 20 Sep 2021 21:30:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

Michael Munday (Gerrit)

unread,
Sep 20, 2021, 5:43:08 PM9/20/21
to goph...@pubsubhelper.golang.org, Keith Randall, Go Bot, golang-co...@googlegroups.com

Attention is currently required from: Keith Randall.

View Change

2 comments:

  • Patchset:

    • Patch Set #1:

      There was another similar CL that went in recently, CL 346050. Is this related to / redundant to / . […]

      Interesting, I wasn't aware of that. Yeah, a generic approach would probably be better. This CL covers more cases than CL 346050. I'll do some experimentation. Thanks Keith!

    • Patch Set #1:

      (There is a bug here: the BGEU rule needs to use an unsigned version of BGTZ, unfortunately BGTUZ doesn't currently exist as a pseudo instruction.)

To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
Gerrit-Change-Number: 350831
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
Gerrit-CC: Go Bot <go...@golang.org>
Gerrit-CC: Keith Randall <k...@golang.org>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-Comment-Date: Mon, 20 Sep 2021 21:43:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Keith Randall <k...@golang.org>
Gerrit-MessageType: comment

Michael Munday (Gerrit)

unread,
Sep 20, 2021, 6:32:33 PM9/20/21
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Keith Randall.

Michael Munday uploaded patch set #2 to this change.

View Change

cmd/compile: use zero constants in comparisons where possible


Some integer comparisons with 1 and -1 can be rewritten as comparisons
with 0. For example, x < 1 is equivalent to x <= 0. This is an
advantageous transformation on riscv64 because comparisons with zero
do not require a constant to be loaded into a register. Other
architectures will likely benefit too and the transformation is
relatively benign on architectures that do not benefit.

Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
---
M src/cmd/compile/internal/ssa/gen/generic.rules
M src/cmd/compile/internal/ssa/rewritegeneric.go
M test/codegen/compare_and_branch.go
3 files changed, 465 insertions(+), 0 deletions(-)

To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
Gerrit-Change-Number: 350831
Gerrit-PatchSet: 2
Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
Gerrit-CC: Go Bot <go...@golang.org>
Gerrit-CC: Keith Randall <k...@golang.org>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-MessageType: newpatchset

Michael Munday (Gerrit)

unread,
Sep 20, 2021, 6:51:08 PM9/20/21
to goph...@pubsubhelper.golang.org, Keith Randall, Go Bot, golang-co...@googlegroups.com

Attention is currently required from: Keith Randall.

Patch set 2:Run-TryBot +1Trust +1

View Change

    To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
    Gerrit-Change-Number: 350831
    Gerrit-PatchSet: 2
    Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
    Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
    Gerrit-CC: Go Bot <go...@golang.org>
    Gerrit-CC: Keith Randall <k...@golang.org>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Comment-Date: Mon, 20 Sep 2021 22:51:02 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Michael Munday (Gerrit)

    unread,
    Sep 21, 2021, 5:58:24 AM9/21/21
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: Michael Munday, Keith Randall.

    Michael Munday uploaded patch set #3 to this change.

    View Change

    cmd/compile: use zero constants in comparisons where possible

    Some integer comparisons with 1 and -1 can be rewritten as comparisons
    with 0. For example, x < 1 is equivalent to x <= 0. This is an
    advantageous transformation on riscv64 because comparisons with zero
    do not require a constant to be loaded into a register. Other
    architectures will likely benefit too and the transformation is
    relatively benign on architectures that do not benefit.

    Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
    ---
    M src/cmd/compile/internal/ssa/gen/generic.rules
    M src/cmd/compile/internal/ssa/rewritegeneric.go
    M test/codegen/compare_and_branch.go
    M test/prove.go
    4 files changed, 466 insertions(+), 1 deletion(-)

    To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
    Gerrit-Change-Number: 350831
    Gerrit-PatchSet: 3
    Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
    Gerrit-Reviewer: Go Bot <go...@golang.org>
    Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
    Gerrit-CC: Keith Randall <k...@golang.org>
    Gerrit-Attention: Michael Munday <mike....@lowrisc.org>

    Michael Munday (Gerrit)

    unread,
    Sep 21, 2021, 6:03:47 AM9/21/21
    to goph...@pubsubhelper.golang.org, Go Bot, Keith Randall, golang-co...@googlegroups.com

    Attention is currently required from: Keith Randall.

    Patch set 3:Run-TryBot +1Trust +1

    View Change

    1 comment:

    To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
    Gerrit-Change-Number: 350831
    Gerrit-PatchSet: 3
    Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
    Gerrit-Reviewer: Go Bot <go...@golang.org>
    Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
    Gerrit-CC: Keith Randall <k...@golang.org>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Comment-Date: Tue, 21 Sep 2021 10:03:42 +0000

    Michael Munday (Gerrit)

    unread,
    Sep 21, 2021, 6:28:07 AM9/21/21
    to goph...@pubsubhelper.golang.org, Go Bot, Keith Randall, golang-co...@googlegroups.com

    Attention is currently required from: Keith Randall.

    View Change

    2 comments:

    • Patchset:

      • Patch Set #1:

        (There is a bug here: the BGEU rule needs to use an unsigned version of BGTZ, unfortunately BGTUZ do […]

        (This is what I get for trying to stay up late doing this sort of stuff - BGTUZ is of course BNEZ).

    • Patchset:

      • Patch Set #3:

        I think the new rules are reasonable but I'm not sure they carry their weight. compilecmp results just looked like noise for riscv64. That said they do improve the code generated in the examples given.

    To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
    Gerrit-Change-Number: 350831
    Gerrit-PatchSet: 3
    Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
    Gerrit-Reviewer: Go Bot <go...@golang.org>
    Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
    Gerrit-CC: Keith Randall <k...@golang.org>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Comment-Date: Tue, 21 Sep 2021 10:28:02 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Michael Munday <mike....@lowrisc.org>
    Gerrit-MessageType: comment

    Michael Munday (Gerrit)

    unread,
    Sep 21, 2021, 6:34:15 AM9/21/21
    to goph...@pubsubhelper.golang.org, Go Bot, Keith Randall, golang-co...@googlegroups.com

    Attention is currently required from: Keith Randall.

    View Change

    1 comment:

    • Patchset:

      • Patch Set #3:

        I think the new rules are reasonable but I'm not sure they carry their weight. […]

        Note to self: double check that this doesn't interfere with range-check detection. Comparisons with 1 seem to often be used to test if the value is within a certain range.

    To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
    Gerrit-Change-Number: 350831
    Gerrit-PatchSet: 3
    Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
    Gerrit-Reviewer: Go Bot <go...@golang.org>
    Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
    Gerrit-CC: Keith Randall <k...@golang.org>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Comment-Date: Tue, 21 Sep 2021 10:34:10 +0000

    Keith Randall (Gerrit)

    unread,
    Sep 21, 2021, 12:32:28 PM9/21/21
    to Michael Munday, goph...@pubsubhelper.golang.org, Keith Randall, Go Bot, golang-co...@googlegroups.com

    Attention is currently required from: Michael Munday.

    Patch set 3:Code-Review +2

    View Change

    1 comment:

    • Patchset:

      • Patch Set #3:

        I'm ok with changes that make the generated code better, even if compilecmp doesn't show a difference. As long as it doesn't show a slowdown.

    To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
    Gerrit-Change-Number: 350831
    Gerrit-PatchSet: 3
    Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
    Gerrit-Reviewer: Go Bot <go...@golang.org>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
    Gerrit-Attention: Michael Munday <mike....@lowrisc.org>
    Gerrit-Comment-Date: Tue, 21 Sep 2021 16:32:24 +0000

    Michael Knyszek (Gerrit)

    unread,
    May 20, 2022, 11:11:03 AM5/20/22
    to Michael Munday, goph...@pubsubhelper.golang.org, Keith Randall, Gopher Robot, golang-co...@googlegroups.com

    Attention is currently required from: Michael Munday.

    Patch set 3:Code-Review +1

    View Change

      To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
      Gerrit-Change-Number: 350831
      Gerrit-PatchSet: 3
      Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      Gerrit-Reviewer: Keith Randall <k...@golang.org>
      Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
      Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
      Gerrit-Attention: Michael Munday <mike....@lowrisc.org>
      Gerrit-Comment-Date: Fri, 20 May 2022 15:10:57 +0000

      Ian Lance Taylor (Gerrit)

      unread,
      May 20, 2022, 7:02:07 PM5/20/22
      to Michael Munday, goph...@pubsubhelper.golang.org, Keith Randall, Gopher Robot, golang-co...@googlegroups.com

      Attention is currently required from: Michael Munday.

      Patch set 3:Code-Review +1

      View Change

        To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
        Gerrit-Change-Number: 350831
        Gerrit-PatchSet: 3
        Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Ian Lance Taylor <ia...@google.com>
        Gerrit-Reviewer: Keith Randall <k...@golang.org>
        Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
        Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
        Gerrit-Attention: Michael Munday <mike....@lowrisc.org>
        Gerrit-Comment-Date: Fri, 20 May 2022 23:02:03 +0000

        Daniel Martí (Gerrit)

        unread,
        Sep 5, 2022, 4:13:17 AM9/5/22
        to Michael Munday, goph...@pubsubhelper.golang.org, Keith Randall, Gopher Robot, golang-co...@googlegroups.com

        Attention is currently required from: Michael Munday.

        View Change

        1 comment:

        • Patchset:

        To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
        Gerrit-Change-Number: 350831
        Gerrit-PatchSet: 3
        Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Ian Lance Taylor <ia...@google.com>
        Gerrit-Reviewer: Keith Randall <k...@golang.org>
        Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
        Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
        Gerrit-CC: Daniel Martí <mv...@mvdan.cc>
        Gerrit-Attention: Michael Munday <mike....@lowrisc.org>
        Gerrit-Comment-Date: Mon, 05 Sep 2022 08:13:10 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Gerrit-MessageType: comment

        Michael Munday (Gerrit)

        unread,
        Feb 26, 2023, 5:28:07 PM2/26/23
        to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

        Attention is currently required from: Michael Munday.

        Michael Munday uploaded patch set #4 to this change.

        View Change

        The following approvals got outdated and were removed: Run-TryBot+1 by Michael Munday, Trust+1 by Michael Munday, TryBot-Result+1 by Gopher Robot

        The change is no longer submittable: TryBots-Pass is unsatisfied now.

        cmd/compile: use zero constants in comparisons where possible

        Some integer comparisons with 1 and -1 can be rewritten as comparisons
        with 0. For example, x < 1 is equivalent to x <= 0. This is an
        advantageous transformation on riscv64 because comparisons with zero
        do not require a constant to be loaded into a register. Other
        architectures will likely benefit too and the transformation is
        relatively benign on architectures that do not benefit.

        Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
        ---
        M src/cmd/compile/internal/ssa/_gen/generic.rules

        M src/cmd/compile/internal/ssa/rewritegeneric.go
        M test/codegen/compare_and_branch.go
        M test/prove.go
        4 files changed, 482 insertions(+), 1 deletion(-)

        To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
        Gerrit-Change-Number: 350831
        Gerrit-PatchSet: 4
        Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Ian Lance Taylor <ia...@google.com>
        Gerrit-Reviewer: Keith Randall <k...@golang.org>
        Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
        Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
        Gerrit-CC: Daniel Martí <mv...@mvdan.cc>
        Gerrit-Attention: Michael Munday <mike....@lowrisc.org>
        Gerrit-MessageType: newpatchset

        Michael Munday (Gerrit)

        unread,
        Feb 26, 2023, 6:38:15 PM2/26/23
        to goph...@pubsubhelper.golang.org, Daniel Martí, Keith Randall, Gopher Robot, golang-co...@googlegroups.com

        Patch set 4:Run-TryBot +1

        View Change

          To view, visit change 350831. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
          Gerrit-Change-Number: 350831
          Gerrit-PatchSet: 4
          Gerrit-Owner: Michael Munday <mike....@lowrisc.org>
          Gerrit-Reviewer: Gopher Robot <go...@golang.org>
          Gerrit-Reviewer: Ian Lance Taylor <ia...@google.com>
          Gerrit-Reviewer: Keith Randall <k...@golang.org>
          Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
          Gerrit-Reviewer: Michael Munday <mike....@lowrisc.org>
          Gerrit-CC: Daniel Martí <mv...@mvdan.cc>
          Gerrit-Comment-Date: Sun, 26 Feb 2023 23:38:10 +0000
          Reply all
          Reply to author
          Forward
          0 new messages