Commit ca6d95cf62 for golang

commit ca6d95cf62db77a39266c012d36ff8c455f4094e
Author: Keith Randall <khr@golang.org>
Date:   Thu Nov 19 14:10:19 2026 -0800

    cmd/compile: don't combine a shift by 0 into EXTRW on arm64

    The rules that combine shiftLL+UBFX should not trigger on c==0,
    as that makes an invalid EXTRW auxint field.

    Change-Id: I48c971f23256da747a1dc7e57e007a5bb5212a83
    Reviewed-on: https://go-review.googlesource.com/c/go/+/866145
    LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
    Reviewed-by: Hongxiang Jiang <hxjiang@golang.org>
    Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
    Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>

diff --git a/src/cmd/compile/internal/ssa/_gen/ARM64.rules b/src/cmd/compile/internal/ssa/_gen/ARM64.rules
index 3c5c1250fa..0e90d5d39e 100644
--- a/src/cmd/compile/internal/ssa/_gen/ARM64.rules
+++ b/src/cmd/compile/internal/ssa/_gen/ARM64.rules
@@ -1631,11 +1631,11 @@
 ( ORshiftLL [c] (SRLconst x [64-c]) x2) => (EXTRconst [64-c] x2 x)
 (XORshiftLL [c] (SRLconst x [64-c]) x2) => (EXTRconst [64-c] x2 x)

-(ADDshiftLL <t> [c] (UBFX [bfc] x) x2) && c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)
+(ADDshiftLL <t> [c] (UBFX [bfc] x) x2) && c > 0 && c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)
 	=> (EXTRWconst [32-c] x2 x)
-( ORshiftLL <t> [c] (UBFX [bfc] x) x2) && c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)
+( ORshiftLL <t> [c] (UBFX [bfc] x) x2) && c > 0 && c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)
 	=> (EXTRWconst [32-c] x2 x)
-(XORshiftLL <t> [c] (UBFX [bfc] x) x2) && c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)
+(XORshiftLL <t> [c] (UBFX [bfc] x) x2) && c > 0 && c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)
 	=> (EXTRWconst [32-c] x2 x)

 // Rewrite special pairs of shifts to AND.
diff --git a/src/cmd/compile/internal/ssa/rewrite/arm64/rewriteARM64.go b/src/cmd/compile/internal/ssa/rewrite/arm64/rewriteARM64.go
index 23eed9086b..fec5207a20 100644
--- a/src/cmd/compile/internal/ssa/rewrite/arm64/rewriteARM64.go
+++ b/src/cmd/compile/internal/ssa/rewrite/arm64/rewriteARM64.go
@@ -4162,7 +4162,7 @@ func rewriteValue_OpARM64ADDshiftLL(v *ssa.Value) bool {
 		return true
 	}
 	// match: (ADDshiftLL <t> [c] (UBFX [bfc] x) x2)
-	// cond: c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)
+	// cond: c > 0 && c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)
 	// result: (EXTRWconst [32-c] x2 x)
 	for {
 		t := v.Type
@@ -4173,7 +4173,7 @@ func rewriteValue_OpARM64ADDshiftLL(v *ssa.Value) bool {
 		bfc := ssa.AuxIntToArm64BitField(v_0.AuxInt)
 		x := v_0.Args[0]
 		x2 := v_1
-		if !(c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)) {
+		if !(c > 0 && c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)) {
 			break
 		}
 		v.Reset(ssaop.OpARM64EXTRWconst)
@@ -16737,7 +16737,7 @@ func rewriteValue_OpARM64ORshiftLL(v *ssa.Value) bool {
 		return true
 	}
 	// match: ( ORshiftLL <t> [c] (UBFX [bfc] x) x2)
-	// cond: c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)
+	// cond: c > 0 && c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)
 	// result: (EXTRWconst [32-c] x2 x)
 	for {
 		t := v.Type
@@ -16748,7 +16748,7 @@ func rewriteValue_OpARM64ORshiftLL(v *ssa.Value) bool {
 		bfc := ssa.AuxIntToArm64BitField(v_0.AuxInt)
 		x := v_0.Args[0]
 		x2 := v_1
-		if !(c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)) {
+		if !(c > 0 && c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)) {
 			break
 		}
 		v.Reset(ssaop.OpARM64EXTRWconst)
@@ -21055,7 +21055,7 @@ func rewriteValue_OpARM64XORshiftLL(v *ssa.Value) bool {
 		return true
 	}
 	// match: (XORshiftLL <t> [c] (UBFX [bfc] x) x2)
-	// cond: c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)
+	// cond: c > 0 && c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)
 	// result: (EXTRWconst [32-c] x2 x)
 	for {
 		t := v.Type
@@ -21066,7 +21066,7 @@ func rewriteValue_OpARM64XORshiftLL(v *ssa.Value) bool {
 		bfc := ssa.AuxIntToArm64BitField(v_0.AuxInt)
 		x := v_0.Args[0]
 		x2 := v_1
-		if !(c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)) {
+		if !(c > 0 && c < 32 && t.Size() == 4 && bfc == ssa.ArmBFAuxInt(32-c, c)) {
 			break
 		}
 		v.Reset(ssaop.OpARM64EXTRWconst)