[go] cmd/compile: correct OffPtr collapsing rule type

1 view
Skip to first unread message

Junyang Shao (Gerrit)

unread,
12:25 PM (10 hours ago) 12:25 PM
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Junyang Shao has uploaded the change for review

Commit message

cmd/compile: correct OffPtr collapsing rule type

It looks like the current way OffPtr is collapsed takes the type of the
first value in the chain, but it should really be the last one in the
chain.
Change-Id: I168804d05f0eb873b1558f76190be03947ad32dc

Change diff

diff --git a/src/cmd/compile/internal/ssa/_gen/generic.rules b/src/cmd/compile/internal/ssa/_gen/generic.rules
index b16aa47..4058906 100644
--- a/src/cmd/compile/internal/ssa/_gen/generic.rules
+++ b/src/cmd/compile/internal/ssa/_gen/generic.rules
@@ -904,7 +904,7 @@
=> mem

// Collapse OffPtr
-(OffPtr (OffPtr p [y]) [x]) => (OffPtr p [x+y])
+(OffPtr (OffPtr <t> p [y]) [x]) => (OffPtr <t> p [x+y])
(OffPtr p [0]) && v.Type.Compare(p.Type) == types.CMPeq => p

// indexing operations
diff --git a/src/cmd/compile/internal/ssa/rewritegeneric.go b/src/cmd/compile/internal/ssa/rewritegeneric.go
index 5e0135b..c7421cd 100644
--- a/src/cmd/compile/internal/ssa/rewritegeneric.go
+++ b/src/cmd/compile/internal/ssa/rewritegeneric.go
@@ -21821,16 +21821,18 @@
}
func rewriteValuegeneric_OpOffPtr(v *Value) bool {
v_0 := v.Args[0]
- // match: (OffPtr (OffPtr p [y]) [x])
- // result: (OffPtr p [x+y])
+ // match: (OffPtr (OffPtr <t> p [y]) [x])
+ // result: (OffPtr <t> p [x+y])
for {
x := auxIntToInt64(v.AuxInt)
if v_0.Op != OpOffPtr {
break
}
+ t := v_0.Type
y := auxIntToInt64(v_0.AuxInt)
p := v_0.Args[0]
v.reset(OpOffPtr)
+ v.Type = t
v.AuxInt = int64ToAuxInt(x + y)
v.AddArg(p)
return true

Change information

Files:
  • M src/cmd/compile/internal/ssa/_gen/generic.rules
  • M src/cmd/compile/internal/ssa/rewritegeneric.go
Change size: XS
Delta: 2 files changed, 5 insertions(+), 3 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: I168804d05f0eb873b1558f76190be03947ad32dc
Gerrit-Change-Number: 708297
Gerrit-PatchSet: 1
Gerrit-Owner: Junyang Shao <shaoj...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Junyang Shao (Gerrit)

unread,
12:25 PM (10 hours ago) 12:25 PM
to goph...@pubsubhelper.golang.org, David Chase, Keith Randall, golang-co...@googlegroups.com
Attention needed from David Chase and Keith Randall

Junyang Shao voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • David Chase
  • Keith Randall
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: I168804d05f0eb873b1558f76190be03947ad32dc
Gerrit-Change-Number: 708297
Gerrit-PatchSet: 1
Gerrit-Owner: Junyang Shao <shaoj...@google.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-Attention: David Chase <drc...@google.com>
Gerrit-Comment-Date: Wed, 01 Oct 2025 16:25:41 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages