[go] cmd/compile: ppc64x fold (x+x)<<c into x<<(c+1)

10 views
Skip to first unread message

Jayanth Krishnamurthy (Gerrit)

unread,
Oct 15, 2025, 5:26:33 AMOct 15
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Jayanth Krishnamurthy has uploaded the change for review

Commit message

cmd/compile: ppc64x fold (x+x)<<c into x<<(c+1)

Add peephole rules to the ppc64x backend.

This removes an unnecessary ADD and shortens the dependency chain for
patterns like (x + x) << c, which is equivalent to x << (c+1). Aligns
ppc64 with other architectures that already assert similar codegen
in shift.go. Safe on ppc64 and ppc64le (POWER8/9/10).

Tests: extend test/codegen/shift.go with ppc64x checks to assert a single
SLD/SLW and forbid ADD.
Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508

Change diff

diff --git a/src/cmd/compile/internal/ssa/_gen/PPC64.rules b/src/cmd/compile/internal/ssa/_gen/PPC64.rules
index f5e381a..36403f8 100644
--- a/src/cmd/compile/internal/ssa/_gen/PPC64.rules
+++ b/src/cmd/compile/internal/ssa/_gen/PPC64.rules
@@ -865,10 +865,14 @@

(SLDconst [c] z:(ANDconst [d] x)) && z.Uses == 1 && isPPC64ValidShiftMask(d) && c <= (64-getPPC64ShiftMaskLength(d)) => (CLRLSLDI [newPPC64ShiftAuxInt(c,64-getPPC64ShiftMaskLength(d),63,64)] x)
(SLDconst [c] z:(AND (MOVDconst [d]) x)) && z.Uses == 1 && isPPC64ValidShiftMask(d) && c<=(64-getPPC64ShiftMaskLength(d)) => (CLRLSLDI [newPPC64ShiftAuxInt(c,64-getPPC64ShiftMaskLength(d),63,64)] x)
+// (x + x) << c → x << (c+1)
+(SLDconst [c] (ADD x x)) => (SLDconst [c+1] x)
(SLWconst [c] z:(MOVBZreg x)) && z.Uses == 1 && c < 8 => (CLRLSLWI [newPPC64ShiftAuxInt(c,24,31,32)] x)
(SLWconst [c] z:(MOVHZreg x)) && z.Uses == 1 && c < 16 => (CLRLSLWI [newPPC64ShiftAuxInt(c,16,31,32)] x)
(SLWconst [c] z:(ANDconst [d] x)) && z.Uses == 1 && isPPC64ValidShiftMask(d) && c<=(32-getPPC64ShiftMaskLength(d)) => (CLRLSLWI [newPPC64ShiftAuxInt(c,32-getPPC64ShiftMaskLength(d),31,32)] x)
(SLWconst [c] z:(AND (MOVDconst [d]) x)) && z.Uses == 1 && isPPC64ValidShiftMask(d) && c<=(32-getPPC64ShiftMaskLength(d)) => (CLRLSLWI [newPPC64ShiftAuxInt(c,32-getPPC64ShiftMaskLength(d),31,32)] x)
+// (x + x) << c → x << (c+1)
+(SLWconst [c] (ADD x x)) => (SLWconst [c+1] x)
// special case for power9
(SL(W|D)const [c] z:(MOVWreg x)) && c < 32 && buildcfg.GOPPC64 >= 9 => (EXTSWSLconst [c] x)

diff --git a/src/cmd/compile/internal/ssa/rewritePPC64.go b/src/cmd/compile/internal/ssa/rewritePPC64.go
index 050ace8..3ae69d7 100644
--- a/src/cmd/compile/internal/ssa/rewritePPC64.go
+++ b/src/cmd/compile/internal/ssa/rewritePPC64.go
@@ -12540,6 +12540,22 @@
}
break
}
+ // match: (SLDconst [c] (ADD x x))
+ // result: (SLDconst [c+1] x)
+ for {
+ c := auxIntToInt64(v.AuxInt)
+ if v_0.Op != OpPPC64ADD {
+ break
+ }
+ x := v_0.Args[1]
+ if x != v_0.Args[0] {
+ break
+ }
+ v.reset(OpPPC64SLDconst)
+ v.AuxInt = int64ToAuxInt(c + 1)
+ v.AddArg(x)
+ return true
+ }
// match: (SLDconst [c] z:(MOVWreg x))
// cond: c < 32 && buildcfg.GOPPC64 >= 9
// result: (EXTSWSLconst [c] x)
@@ -12676,6 +12692,22 @@
}
break
}
+ // match: (SLWconst [c] (ADD x x))
+ // result: (SLWconst [c+1] x)
+ for {
+ c := auxIntToInt64(v.AuxInt)
+ if v_0.Op != OpPPC64ADD {
+ break
+ }
+ x := v_0.Args[1]
+ if x != v_0.Args[0] {
+ break
+ }
+ v.reset(OpPPC64SLWconst)
+ v.AuxInt = int64ToAuxInt(c + 1)
+ v.AddArg(x)
+ return true
+ }
// match: (SLWconst [c] z:(MOVWreg x))
// cond: c < 32 && buildcfg.GOPPC64 >= 9
// result: (EXTSWSLconst [c] x)
diff --git a/test/codegen/shift.go b/test/codegen/shift.go
index 4b0885a..2375e16 100644
--- a/test/codegen/shift.go
+++ b/test/codegen/shift.go
@@ -123,6 +123,7 @@
// amd64:"SHLL\t[$]2"
// loong64:"SLL\t[$]2"
// riscv64:"SLLI\t[$]2"
+ // ppc64x:"SLW\t[$]2"-"ADD"
return (x + x) << 1
}

@@ -130,6 +131,7 @@
// amd64:"SHLQ\t[$]2"
// loong64:"SLLV\t[$]2"
// riscv64:"SLLI\t[$]2"
+ // ppc64x:"SLD\t[$]2"-"ADD"
return (x + x) << 1
}

@@ -137,6 +139,7 @@
// amd64:"SHLL\t[$]3"
// loong64:"SLL\t[$]3"
// riscv64:"SLLI\t[$]3"
+ // ppc64x:"SLW\t[$]3"-"ADD"
return (x + x) << 2
}

@@ -144,6 +147,7 @@
// amd64:"SHLQ\t[$]3"
// loong64:"SLLV\t[$]3"
// riscv64:"SLLI\t[$]3"
+ // ppc64x:"SLD\t[$]3"-"ADD"
return (x + x) << 2
}

Change information

Files:
  • M src/cmd/compile/internal/ssa/_gen/PPC64.rules
  • M src/cmd/compile/internal/ssa/rewritePPC64.go
  • M test/codegen/shift.go
Change size: S
Delta: 3 files changed, 40 insertions(+), 0 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
Gerrit-Change-Number: 712000
Gerrit-PatchSet: 1
Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Jayanth Krishnamurthy (Gerrit)

unread,
Oct 15, 2025, 5:45:25 AMOct 15
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Keith Randall and Martin Möhrmann

Jayanth Krishnamurthy uploaded new patchset

Jayanth Krishnamurthy uploaded patch set #2 to this change.
Open in Gerrit

Related details

Attention is currently required from:
  • Keith Randall
  • Martin Möhrmann
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
Gerrit-Change-Number: 712000
Gerrit-PatchSet: 2
Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Martin Möhrmann <moeh...@google.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-Attention: Martin Möhrmann <moeh...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Jayanth Krishnamurthy (Gerrit)

unread,
Oct 15, 2025, 5:46:17 AMOct 15
to goph...@pubsubhelper.golang.org, Keith Randall, Martin Möhrmann, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Martin Möhrmann

Jayanth Krishnamurthy removed Keith Randall from this change

Deleted Reviewers:
  • Keith Randall
Open in Gerrit

Related details

Attention is currently required from:
  • Martin Möhrmann
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: deleteReviewer
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
Gerrit-Change-Number: 712000
Gerrit-PatchSet: 2
Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
Gerrit-Reviewer: Martin Möhrmann <moeh...@google.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Attention: Martin Möhrmann <moeh...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Jayanth Krishnamurthy (Gerrit)

unread,
Oct 15, 2025, 5:46:25 AMOct 15
to goph...@pubsubhelper.golang.org, Martin Möhrmann, Gopher Robot, golang-co...@googlegroups.com

Jayanth Krishnamurthy removed Martin Möhrmann from this change

Deleted Reviewers:
  • Martin Möhrmann
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: deleteReviewer
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
Gerrit-Change-Number: 712000
Gerrit-PatchSet: 2
Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
unsatisfied_requirement
satisfied_requirement
open
diffy

Jayanth Krishnamurthy (Gerrit)

unread,
Oct 15, 2025, 5:47:28 AMOct 15
to goph...@pubsubhelper.golang.org, Archana Ravindar, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Archana Ravindar

Jayanth Krishnamurthy voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Archana Ravindar
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
Gerrit-Change-Number: 712000
Gerrit-PatchSet: 2
Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
Gerrit-Reviewer: Archana Ravindar <arav...@redhat.com>
Gerrit-Reviewer: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Attention: Archana Ravindar <arav...@redhat.com>
Gerrit-Comment-Date: Wed, 15 Oct 2025 09:47:21 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Jayanth Krishnamurthy (Gerrit)

unread,
Oct 15, 2025, 5:48:48 AMOct 15
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Archana Ravindar

Jayanth Krishnamurthy uploaded new patchset

Jayanth Krishnamurthy uploaded patch set #3 to this change.
Open in Gerrit

Related details

Attention is currently required from:
  • Archana Ravindar
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
Gerrit-Change-Number: 712000
Gerrit-PatchSet: 3
Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
Gerrit-Reviewer: Archana Ravindar <arav...@redhat.com>
Gerrit-Reviewer: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Jayanth Krishnamurthy (Gerrit)

unread,
Oct 15, 2025, 5:49:03 AMOct 15
to goph...@pubsubhelper.golang.org, Go LUCI, Archana Ravindar, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Archana Ravindar and Jayanth Krishnamurthy

Jayanth Krishnamurthy voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Archana Ravindar
  • Jayanth Krishnamurthy
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
Gerrit-Change-Number: 712000
Gerrit-PatchSet: 3
Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
Gerrit-Reviewer: Archana Ravindar <arav...@redhat.com>
Gerrit-Reviewer: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Attention: Archana Ravindar <arav...@redhat.com>
Gerrit-Attention: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
Gerrit-Comment-Date: Wed, 15 Oct 2025 09:48:57 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Jayanth Krishnamurthy (Gerrit)

unread,
Oct 15, 2025, 5:50:02 AMOct 15
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Archana Ravindar and Jayanth Krishnamurthy

Jayanth Krishnamurthy uploaded new patchset

Jayanth Krishnamurthy uploaded patch set #4 to this change.
Open in Gerrit

Related details

Attention is currently required from:
  • Archana Ravindar
  • Jayanth Krishnamurthy
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
Gerrit-Change-Number: 712000
Gerrit-PatchSet: 4
unsatisfied_requirement
satisfied_requirement
open
diffy

Jayanth Krishnamurthy (Gerrit)

unread,
Oct 15, 2025, 5:50:20 AMOct 15
to goph...@pubsubhelper.golang.org, Go LUCI, Archana Ravindar, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Archana Ravindar

Jayanth Krishnamurthy voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Archana Ravindar
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
Gerrit-Change-Number: 712000
Gerrit-PatchSet: 4
Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
Gerrit-Reviewer: Archana Ravindar <arav...@redhat.com>
Gerrit-Reviewer: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Attention: Archana Ravindar <arav...@redhat.com>
Gerrit-Comment-Date: Wed, 15 Oct 2025 09:50:11 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Jayanth Krishnamurthy (Gerrit)

unread,
Oct 15, 2025, 6:54:29 AMOct 15
to goph...@pubsubhelper.golang.org, Go LUCI, Archana Ravindar, Gopher Robot, golang-co...@googlegroups.com
Gerrit-Comment-Date: Wed, 15 Oct 2025 10:54:21 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Michael Munday (Gerrit)

unread,
Oct 15, 2025, 7:35:22 AMOct 15
to Jayanth Krishnamurthy, goph...@pubsubhelper.golang.org, Go LUCI, Archana Ravindar, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Archana Ravindar and Jayanth Krishnamurthy

Michael Munday added 2 comments

File src/cmd/compile/internal/ssa/_gen/PPC64.rules
Line 869, Patchset 4 (Latest):(SLDconst [c] (ADD x x)) => (SLDconst [c+1] x)
Michael Munday . unresolved

Do you need to check if c+1 is less than 64 here?

Line 875, Patchset 4 (Latest):(SLWconst [c] (ADD x x)) => (SLWconst [c+1] x)
Michael Munday . unresolved

Ditto for 32.

Open in Gerrit

Related details

Attention is currently required from:
  • Archana Ravindar
  • Jayanth Krishnamurthy
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
    Gerrit-Change-Number: 712000
    Gerrit-PatchSet: 4
    Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
    Gerrit-Reviewer: Archana Ravindar <arav...@redhat.com>
    Gerrit-Reviewer: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Michael Munday <mike...@gmail.com>
    Gerrit-Attention: Archana Ravindar <arav...@redhat.com>
    Gerrit-Attention: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
    Gerrit-Comment-Date: Wed, 15 Oct 2025 11:35:12 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Jayanth Krishnamurthy (Gerrit)

    unread,
    Oct 15, 2025, 8:08:42 AMOct 15
    to goph...@pubsubhelper.golang.org, Michael Munday, Go LUCI, Archana Ravindar, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Archana Ravindar and Michael Munday

    Jayanth Krishnamurthy voted and added 2 comments

    Votes added by Jayanth Krishnamurthy

    Commit-Queue+1

    2 comments

    File src/cmd/compile/internal/ssa/_gen/PPC64.rules
    Line 869, Patchset 4 (Latest):(SLDconst [c] (ADD x x)) => (SLDconst [c+1] x)
    Michael Munday . resolved

    Do you need to check if c+1 is less than 64 here?

    Jayanth Krishnamurthy

    Thanks!. I believe no extra guard is needed here.
    At the boundary c = w-1 (w = bit width),
    (x + x) << (w-1) = (2x) << (w-1) = x << w = 0

    since 2x is always even and Go’s constant-shift semantics define x << w (shift ≥ width) as 0 for integer types.

    So for 64-bit, (x+x)<<63 and x<<64 are both 0 for all x (same for 32-bit).

    I can add guards (c < 63 / c < 31) if you prefer the explicit style, but they may not be required for correctness.

    Line 875, Patchset 4 (Latest):(SLWconst [c] (ADD x x)) => (SLWconst [c+1] x)
    Michael Munday . resolved

    Ditto for 32.

    Jayanth Krishnamurthy

    Acknowledged

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Archana Ravindar
    • Michael Munday
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
      Gerrit-Change-Number: 712000
      Gerrit-PatchSet: 4
      Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
      Gerrit-Reviewer: Archana Ravindar <arav...@redhat.com>
      Gerrit-Reviewer: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-CC: Michael Munday <mike...@gmail.com>
      Gerrit-Attention: Archana Ravindar <arav...@redhat.com>
      Gerrit-Attention: Michael Munday <mike...@gmail.com>
      Gerrit-Comment-Date: Wed, 15 Oct 2025 12:08:33 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Michael Munday <mike...@gmail.com>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Michael Munday (Gerrit)

      unread,
      Oct 15, 2025, 10:56:49 AMOct 15
      to Jayanth Krishnamurthy, goph...@pubsubhelper.golang.org, Go LUCI, Archana Ravindar, Gopher Robot, golang-co...@googlegroups.com
      Attention needed from Archana Ravindar and Jayanth Krishnamurthy

      Michael Munday added 1 comment

      File src/cmd/compile/internal/ssa/_gen/PPC64.rules
      Line 869, Patchset 4 (Latest):(SLDconst [c] (ADD x x)) => (SLDconst [c+1] x)
      Michael Munday . unresolved

      Do you need to check if c+1 is less than 64 here?

      Jayanth Krishnamurthy

      Thanks!. I believe no extra guard is needed here.
      At the boundary c = w-1 (w = bit width),
      (x + x) << (w-1) = (2x) << (w-1) = x << w = 0

      since 2x is always even and Go’s constant-shift semantics define x << w (shift ≥ width) as 0 for integer types.

      So for 64-bit, (x+x)<<63 and x<<64 are both 0 for all x (same for 32-bit).

      I can add guards (c < 63 / c < 31) if you prefer the explicit style, but they may not be required for correctness.

      Michael Munday

      Go's shift semantics aren't relevant at this point in the compiler. These rules lower the program into ppc64 instructions.

      The shift amount when using the sldi instruction on ppc64 is represented using 6 bits. A shift amount of 64 will therefore either be silently truncated to 0 or an error will be raised by the assembler, I'm not sure which. Therefore I think there does need to be a check that c+1 is less than 64 for correctness.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Archana Ravindar
      • Jayanth Krishnamurthy
      Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
        Gerrit-Change-Number: 712000
        Gerrit-PatchSet: 4
        Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
        Gerrit-Reviewer: Archana Ravindar <arav...@redhat.com>
        Gerrit-Reviewer: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Michael Munday <mike...@gmail.com>
        Gerrit-Attention: Archana Ravindar <arav...@redhat.com>
        Gerrit-Attention: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
        Gerrit-Comment-Date: Wed, 15 Oct 2025 14:56:39 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
        Comment-In-Reply-To: Michael Munday <mike...@gmail.com>
        unsatisfied_requirement
        open
        diffy

        Jayanth Krishnamurthy (Gerrit)

        unread,
        Oct 15, 2025, 11:40:49 AMOct 15
        to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from Archana Ravindar and Jayanth Krishnamurthy

        Jayanth Krishnamurthy uploaded new patchset

        Jayanth Krishnamurthy uploaded patch set #5 to this change.
        Following approvals got outdated and were removed:
        • TryBots-Pass: LUCI-TryBot-Result-1 by Go LUCI
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Archana Ravindar
        • Jayanth Krishnamurthy
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: newpatchset
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
        Gerrit-Change-Number: 712000
        Gerrit-PatchSet: 5
        unsatisfied_requirement
        open
        diffy

        Jayanth Krishnamurthy (Gerrit)

        unread,
        Oct 15, 2025, 11:54:40 AMOct 15
        to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from Archana Ravindar and Jayanth Krishnamurthy

        Jayanth Krishnamurthy uploaded new patchset

        Jayanth Krishnamurthy uploaded patch set #6 to this change.
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Archana Ravindar
        • Jayanth Krishnamurthy
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: newpatchset
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
        Gerrit-Change-Number: 712000
        Gerrit-PatchSet: 6
        unsatisfied_requirement
        open
        diffy

        Jayanth Krishnamurthy (Gerrit)

        unread,
        Oct 15, 2025, 12:14:59 PMOct 15
        to goph...@pubsubhelper.golang.org, Michael Munday, Go LUCI, Archana Ravindar, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Archana Ravindar and Michael Munday

        Jayanth Krishnamurthy voted and added 1 comment

        Votes added by Jayanth Krishnamurthy

        Commit-Queue+1

        1 comment

        File src/cmd/compile/internal/ssa/_gen/PPC64.rules
        Line 869, Patchset 4:(SLDconst [c] (ADD x x)) => (SLDconst [c+1] x)
        Michael Munday . resolved

        Do you need to check if c+1 is less than 64 here?

        Jayanth Krishnamurthy

        Thanks!. I believe no extra guard is needed here.
        At the boundary c = w-1 (w = bit width),
        (x + x) << (w-1) = (2x) << (w-1) = x << w = 0

        since 2x is always even and Go’s constant-shift semantics define x << w (shift ≥ width) as 0 for integer types.

        So for 64-bit, (x+x)<<63 and x<<64 are both 0 for all x (same for 32-bit).

        I can add guards (c < 63 / c < 31) if you prefer the explicit style, but they may not be required for correctness.

        Michael Munday

        Go's shift semantics aren't relevant at this point in the compiler. These rules lower the program into ppc64 instructions.

        The shift amount when using the sldi instruction on ppc64 is represented using 6 bits. A shift amount of 64 will therefore either be silently truncated to 0 or an error will be raised by the assembler, I'm not sure which. Therefore I think there does need to be a check that c+1 is less than 64 for correctness.

        Jayanth Krishnamurthy

        Thanks for the pointer on immediate ranges — I have added guards so the folded immediates stay encodable. If you suggest explicit boundary tests (to assert no fold at c=63/31), I’m happy to add them in this CL.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Archana Ravindar
        • Michael Munday
        Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          • requirement is not satisfiedTryBots-Pass
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
          Gerrit-Change-Number: 712000
          Gerrit-PatchSet: 6
          Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
          Gerrit-Reviewer: Archana Ravindar <arav...@redhat.com>
          Gerrit-Reviewer: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
          Gerrit-CC: Gopher Robot <go...@golang.org>
          Gerrit-CC: Michael Munday <mike...@gmail.com>
          Gerrit-Attention: Archana Ravindar <arav...@redhat.com>
          Gerrit-Attention: Michael Munday <mike...@gmail.com>
          Gerrit-Comment-Date: Wed, 15 Oct 2025 16:14:51 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Jayanth Krishnamurthy (Gerrit)

          unread,
          Oct 16, 2025, 1:18:58 AMOct 16
          to goph...@pubsubhelper.golang.org, Go LUCI, Michael Munday, Archana Ravindar, Gopher Robot, golang-co...@googlegroups.com
          Attention needed from Archana Ravindar and Michael Munday

          Jayanth Krishnamurthy voted Commit-Queue+1

          Commit-Queue+1
          Gerrit-Comment-Date: Thu, 16 Oct 2025 05:18:50 +0000
          Gerrit-HasComments: No
          Gerrit-Has-Labels: Yes
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Michael Munday (Gerrit)

          unread,
          Oct 21, 2025, 5:20:45 PMOct 21
          to Jayanth Krishnamurthy, goph...@pubsubhelper.golang.org, Go LUCI, Archana Ravindar, Gopher Robot, golang-co...@googlegroups.com
          Attention needed from Archana Ravindar and Jayanth Krishnamurthy

          Michael Munday voted and added 1 comment

          Votes added by Michael Munday

          Code-Review+1

          1 comment

          Patchset-level comments
          File-level comment, Patchset 6 (Latest):
          Michael Munday . resolved

          LGTM

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Archana Ravindar
          • Jayanth Krishnamurthy
          Submit Requirements:
            • requirement is not satisfiedCode-Review
            • requirement satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            • requirement satisfiedTryBots-Pass
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
            Gerrit-Change-Number: 712000
            Gerrit-PatchSet: 6
            Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
            Gerrit-Reviewer: Archana Ravindar <arav...@redhat.com>
            Gerrit-Reviewer: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
            Gerrit-Reviewer: Michael Munday <mike...@gmail.com>
            Gerrit-CC: Gopher Robot <go...@golang.org>
            Gerrit-Attention: Archana Ravindar <arav...@redhat.com>
            Gerrit-Attention: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
            Gerrit-Comment-Date: Tue, 21 Oct 2025 21:20:37 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: Yes
            unsatisfied_requirement
            satisfied_requirement
            open
            diffy

            Paul Murphy (Gerrit)

            unread,
            Nov 10, 2025, 4:05:42 PM (3 days ago) Nov 10
            to Jayanth Krishnamurthy, goph...@pubsubhelper.golang.org, Michael Munday, Go LUCI, Archana Ravindar, Gopher Robot, golang-co...@googlegroups.com
            Attention needed from Archana Ravindar and Jayanth Krishnamurthy

            Paul Murphy voted and added 1 comment

            Votes added by Paul Murphy

            Code-Review+2

            1 comment

            File test/codegen/shift.go
            Line 156, Patchset 6 (Latest): // riscv64:-"SLLI","MOV\t[$]0"
            Paul Murphy . unresolved

            Can you implement a check for ppc64x here too?

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Archana Ravindar
            • Jayanth Krishnamurthy
            Submit Requirements:
            • requirement satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            • requirement satisfiedTryBots-Pass
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
            Gerrit-Change-Number: 712000
            Gerrit-PatchSet: 6
            Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
            Gerrit-Reviewer: Archana Ravindar <arav...@redhat.com>
            Gerrit-Reviewer: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
            Gerrit-Reviewer: Michael Munday <mike...@gmail.com>
            Gerrit-Reviewer: Paul Murphy <paum...@redhat.com>
            Gerrit-CC: Gopher Robot <go...@golang.org>
            Gerrit-Attention: Archana Ravindar <arav...@redhat.com>
            Gerrit-Attention: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
            Gerrit-Comment-Date: Mon, 10 Nov 2025 21:05:38 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: Yes
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Jayanth Krishnamurthy (Gerrit)

            unread,
            Nov 11, 2025, 4:06:20 PM (2 days ago) Nov 11
            to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
            Attention needed from Archana Ravindar, Jayanth Krishnamurthy, Michael Munday and Paul Murphy

            Jayanth Krishnamurthy uploaded new patchset

            Jayanth Krishnamurthy uploaded patch set #7 to this change.
            Following approvals got outdated and were removed:
            • Code-Review: +1 by Michael Munday, +2 by Paul Murphy
            • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
            Open in Gerrit

            Related details

            Attention is currently required from:
            • Archana Ravindar
            • Jayanth Krishnamurthy
            • Michael Munday
            • Paul Murphy
            Submit Requirements:
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            • requirement is not satisfiedTryBots-Pass
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: newpatchset
            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
            Gerrit-Change-Number: 712000
            Gerrit-PatchSet: 7
            Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
            Gerrit-Reviewer: Archana Ravindar <arav...@redhat.com>
            Gerrit-Reviewer: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
            Gerrit-Reviewer: Michael Munday <mike...@gmail.com>
            Gerrit-Reviewer: Paul Murphy <paum...@redhat.com>
            Gerrit-CC: Gopher Robot <go...@golang.org>
            Gerrit-Attention: Archana Ravindar <arav...@redhat.com>
            Gerrit-Attention: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
            Gerrit-Attention: Paul Murphy <paum...@redhat.com>
            Gerrit-Attention: Michael Munday <mike...@gmail.com>
            unsatisfied_requirement
            open
            diffy

            Jayanth Krishnamurthy (Gerrit)

            unread,
            Nov 11, 2025, 4:07:02 PM (2 days ago) Nov 11
            to goph...@pubsubhelper.golang.org, Paul Murphy, Michael Munday, Go LUCI, Archana Ravindar, Gopher Robot, golang-co...@googlegroups.com
            Attention needed from Archana Ravindar, Michael Munday and Paul Murphy

            Jayanth Krishnamurthy voted and added 1 comment

            Votes added by Jayanth Krishnamurthy

            Commit-Queue+1

            1 comment

            File test/codegen/shift.go
            Line 156, Patchset 6: // riscv64:-"SLLI","MOV\t[$]0"
            Paul Murphy . resolved

            Can you implement a check for ppc64x here too?

            Jayanth Krishnamurthy

            Acknowledged

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Archana Ravindar
            • Michael Munday
            • Paul Murphy
            Submit Requirements:
              • requirement is not satisfiedCode-Review
              • requirement satisfiedNo-Unresolved-Comments
              • requirement is not satisfiedReview-Enforcement
              • requirement is not satisfiedTryBots-Pass
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: go
              Gerrit-Branch: master
              Gerrit-Change-Id: Ie564afbb029a5bd48887b82b0c455ca1dddd5508
              Gerrit-Change-Number: 712000
              Gerrit-PatchSet: 7
              Gerrit-Owner: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
              Gerrit-Reviewer: Archana Ravindar <arav...@redhat.com>
              Gerrit-Reviewer: Jayanth Krishnamurthy <jayanth.kr...@ibm.com>
              Gerrit-Reviewer: Michael Munday <mike...@gmail.com>
              Gerrit-Reviewer: Paul Murphy <paum...@redhat.com>
              Gerrit-CC: Gopher Robot <go...@golang.org>
              Gerrit-Attention: Archana Ravindar <arav...@redhat.com>
              Gerrit-Attention: Paul Murphy <paum...@redhat.com>
              Gerrit-Attention: Michael Munday <mike...@gmail.com>
              Gerrit-Comment-Date: Tue, 11 Nov 2025 21:06:55 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: Yes
              Comment-In-Reply-To: Paul Murphy <paum...@redhat.com>
              unsatisfied_requirement
              satisfied_requirement
              open
              diffy
              Reply all
              Reply to author
              Forward
              0 new messages