Skip to content

Commit 4e78285

Browse files
committed
cmd/compile/internal/ssa/_gen: disallow op variable name
We're reserving this so that 'op' can now be used for the import of the op package we're adding without having to rename the import. Rename the variables in generic.rules that use the op name to use op1 and regenerate. For #80409 Change-Id: I8501c1cc3f3763a4890e8453b48452b76a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/803780 LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
1 parent 63741ea commit 4e78285

3 files changed

Lines changed: 523 additions & 522 deletions

File tree

src/cmd/compile/internal/ssa/_gen/generic.rules

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -844,10 +844,10 @@
844844
=> x
845845

846846
// Load from a region just copied by Move can read directly from the source.
847-
(Load <t1> op:(OffPtr [o1] p1) move:(Move [n] p2 src mem))
847+
(Load <t1> op1:(OffPtr [o1] p1) move:(Move [n] p2 src mem))
848848
&& o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p2)
849849
&& !isVolatile(src)
850-
=> @move.Block (Load <t1> (OffPtr <op.Type> [o1] src) mem)
850+
=> @move.Block (Load <t1> (OffPtr <op1.Type> [o1] src) mem)
851851

852852
// Pass constants through math.Float{32,64}bits and math.Float{32,64}frombits
853853
(Load <t1> p1 (Store {t2} p2 (Const64 [x]) _)) && isSamePtr(p1,p2) && t2.Size() == 8 && is64BitFloat(t1) && !math.IsNaN(math.Float64frombits(uint64(x))) => (Const64F [math.Float64frombits(uint64(x))])
@@ -856,46 +856,46 @@
856856
(Load <t1> p1 (Store {t2} p2 (Const32F [x]) _)) && isSamePtr(p1,p2) && t2.Size() == 4 && is32BitInt(t1) => (Const32 [int32(math.Float32bits(x))])
857857

858858
// Float Loads up to Zeros so they can be constant folded.
859-
(Load <t1> op:(OffPtr [o1] p1)
859+
(Load <t1> op1:(OffPtr [o1] p1)
860860
(Store {t2} p2 _
861861
mem:(Zero [n] p3 _)))
862862
&& o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p3)
863863
&& CanSSA(t1)
864-
&& disjoint(op, t1.Size(), p2, t2.Size())
865-
=> @mem.Block (Load <t1> (OffPtr <op.Type> [o1] p3) mem)
866-
(Load <t1> op:(OffPtr [o1] p1)
864+
&& disjoint(op1, t1.Size(), p2, t2.Size())
865+
=> @mem.Block (Load <t1> (OffPtr <op1.Type> [o1] p3) mem)
866+
(Load <t1> op1:(OffPtr [o1] p1)
867867
(Store {t2} p2 _
868868
(Store {t3} p3 _
869869
mem:(Zero [n] p4 _))))
870870
&& o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p4)
871871
&& CanSSA(t1)
872-
&& disjoint(op, t1.Size(), p2, t2.Size())
873-
&& disjoint(op, t1.Size(), p3, t3.Size())
874-
=> @mem.Block (Load <t1> (OffPtr <op.Type> [o1] p4) mem)
875-
(Load <t1> op:(OffPtr [o1] p1)
872+
&& disjoint(op1, t1.Size(), p2, t2.Size())
873+
&& disjoint(op1, t1.Size(), p3, t3.Size())
874+
=> @mem.Block (Load <t1> (OffPtr <op1.Type> [o1] p4) mem)
875+
(Load <t1> op1:(OffPtr [o1] p1)
876876
(Store {t2} p2 _
877877
(Store {t3} p3 _
878878
(Store {t4} p4 _
879879
mem:(Zero [n] p5 _)))))
880880
&& o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p5)
881881
&& CanSSA(t1)
882-
&& disjoint(op, t1.Size(), p2, t2.Size())
883-
&& disjoint(op, t1.Size(), p3, t3.Size())
884-
&& disjoint(op, t1.Size(), p4, t4.Size())
885-
=> @mem.Block (Load <t1> (OffPtr <op.Type> [o1] p5) mem)
886-
(Load <t1> op:(OffPtr [o1] p1)
882+
&& disjoint(op1, t1.Size(), p2, t2.Size())
883+
&& disjoint(op1, t1.Size(), p3, t3.Size())
884+
&& disjoint(op1, t1.Size(), p4, t4.Size())
885+
=> @mem.Block (Load <t1> (OffPtr <op1.Type> [o1] p5) mem)
886+
(Load <t1> op1:(OffPtr [o1] p1)
887887
(Store {t2} p2 _
888888
(Store {t3} p3 _
889889
(Store {t4} p4 _
890890
(Store {t5} p5 _
891891
mem:(Zero [n] p6 _))))))
892892
&& o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p6)
893893
&& CanSSA(t1)
894-
&& disjoint(op, t1.Size(), p2, t2.Size())
895-
&& disjoint(op, t1.Size(), p3, t3.Size())
896-
&& disjoint(op, t1.Size(), p4, t4.Size())
897-
&& disjoint(op, t1.Size(), p5, t5.Size())
898-
=> @mem.Block (Load <t1> (OffPtr <op.Type> [o1] p6) mem)
894+
&& disjoint(op1, t1.Size(), p2, t2.Size())
895+
&& disjoint(op1, t1.Size(), p3, t3.Size())
896+
&& disjoint(op1, t1.Size(), p4, t4.Size())
897+
&& disjoint(op1, t1.Size(), p5, t5.Size())
898+
=> @mem.Block (Load <t1> (OffPtr <op1.Type> [o1] p6) mem)
899899

900900
// Zero to Load forwarding.
901901
(Load <t1> (OffPtr [o] p1) (Zero [n] p2 _))
@@ -964,23 +964,23 @@
964964
&& isConstZero(x)
965965
&& o >= 0 && t.Size() + o <= n && isSamePtr(p1, p2)
966966
=> mem
967-
(Store {t1} op:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Zero [n] p3 _)))
967+
(Store {t1} op1:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Zero [n] p3 _)))
968968
&& isConstZero(x)
969969
&& o1 >= 0 && t1.Size() + o1 <= n && isSamePtr(p1, p3)
970-
&& disjoint(op, t1.Size(), p2, t2.Size())
970+
&& disjoint(op1, t1.Size(), p2, t2.Size())
971971
=> mem
972-
(Store {t1} op:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Store {t3} p3 _ (Zero [n] p4 _))))
972+
(Store {t1} op1:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Store {t3} p3 _ (Zero [n] p4 _))))
973973
&& isConstZero(x)
974974
&& o1 >= 0 && t1.Size() + o1 <= n && isSamePtr(p1, p4)
975-
&& disjoint(op, t1.Size(), p2, t2.Size())
976-
&& disjoint(op, t1.Size(), p3, t3.Size())
975+
&& disjoint(op1, t1.Size(), p2, t2.Size())
976+
&& disjoint(op1, t1.Size(), p3, t3.Size())
977977
=> mem
978-
(Store {t1} op:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Store {t3} p3 _ (Store {t4} p4 _ (Zero [n] p5 _)))))
978+
(Store {t1} op1:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Store {t3} p3 _ (Store {t4} p4 _ (Zero [n] p5 _)))))
979979
&& isConstZero(x)
980980
&& o1 >= 0 && t1.Size() + o1 <= n && isSamePtr(p1, p5)
981-
&& disjoint(op, t1.Size(), p2, t2.Size())
982-
&& disjoint(op, t1.Size(), p3, t3.Size())
983-
&& disjoint(op, t1.Size(), p4, t4.Size())
981+
&& disjoint(op1, t1.Size(), p2, t2.Size())
982+
&& disjoint(op1, t1.Size(), p3, t3.Size())
983+
&& disjoint(op1, t1.Size(), p4, t4.Size())
984984
=> mem
985985

986986
// Collapse OffPtr
@@ -1771,10 +1771,10 @@
17711771
&& n >= o2 + t2.Size()
17721772
&& clobber(store)
17731773
=> (Zero {t1} [n] p1 mem)
1774-
(Move {t1} [n] dst1 src1 store:(Store {t2} op:(OffPtr [o2] dst2) _ mem))
1774+
(Move {t1} [n] dst1 src1 store:(Store {t2} op1:(OffPtr [o2] dst2) _ mem))
17751775
&& isSamePtr(dst1, dst2) && store.Uses == 1
17761776
&& n >= o2 + t2.Size()
1777-
&& disjoint(src1, n, op, t2.Size())
1777+
&& disjoint(src1, n, op1, t2.Size())
17781778
&& clobber(store)
17791779
=> (Move {t1} [n] dst1 src1 mem)
17801780

@@ -2344,37 +2344,37 @@
23442344

23452345
// Transform some CondSelect into math operations.
23462346
// if b { x += c } => x += b * c
2347-
(CondSelect op:(Add8 <t> x c:(Const8)) x bool) &&
2348-
rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) =>
2347+
(CondSelect op1:(Add8 <t> x c:(Const8)) x bool) &&
2348+
rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) =>
23492349
(Add8 x (Mul8 <t> c (CvtBoolToUint8 <t> bool)))
2350-
(CondSelect op:(Add(64|32|16) <t> x c:(Const(64|32|16))) x bool) &&
2351-
rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) =>
2350+
(CondSelect op1:(Add(64|32|16) <t> x c:(Const(64|32|16))) x bool) &&
2351+
rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) =>
23522352
(Add(64|32|16) x (Mul(64|32|16) <t> c (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> bool))))
23532353
// if !b { x += c } => x += !b * c
2354-
(CondSelect x op:(Add8 <t> x c:(Const8)) bool) &&
2355-
rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) =>
2354+
(CondSelect x op1:(Add8 <t> x c:(Const8)) bool) &&
2355+
rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) =>
23562356
(Add8 x (Mul8 <t> c (CvtBoolToUint8 <t> (Not <bool.Type> bool))))
2357-
(CondSelect x op:(Add(64|32|16) <t> x c:(Const(64|32|16))) bool) &&
2358-
rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) =>
2357+
(CondSelect x op1:(Add(64|32|16) <t> x c:(Const(64|32|16))) bool) &&
2358+
rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) =>
23592359
(Add(64|32|16) x (Mul(64|32|16) <t> c (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> (Not <bool.Type> bool)))))
23602360

23612361
// if b { x += c } => x -= b * -c // looks redundant but useful if the arch can inline materialize -c but not c
2362-
(CondSelect op:(Add8 <t> x c:(Const8 [consT])) x bool) &&
2363-
!rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) &&
2364-
rewriteCondSelectIntoMath(config, addToSub(op.Op), -c.AuxInt) =>
2362+
(CondSelect op1:(Add8 <t> x c:(Const8 [consT])) x bool) &&
2363+
!rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) &&
2364+
rewriteCondSelectIntoMath(config, addToSub(op1.Op), -c.AuxInt) =>
23652365
(Sub8 x (Mul8 <t> (Const8 <t> [-consT]) (CvtBoolToUint8 <t> bool)))
2366-
(CondSelect op:(Add(64|32|16) <t> x c:(Const(64|32|16) [consT])) x bool) &&
2367-
!rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) &&
2368-
rewriteCondSelectIntoMath(config, addToSub(op.Op), -c.AuxInt) =>
2366+
(CondSelect op1:(Add(64|32|16) <t> x c:(Const(64|32|16) [consT])) x bool) &&
2367+
!rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) &&
2368+
rewriteCondSelectIntoMath(config, addToSub(op1.Op), -c.AuxInt) =>
23692369
(Sub(64|32|16) x (Mul(64|32|16) <t> (Const(64|32|16) <t> [-consT]) (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> bool))))
23702370
// if !b { x += c } => x -= !b * -c // looks redundant but useful if the arch can inline materialize -c but not c
2371-
(CondSelect x op:(Add8 <t> x c:(Const8 [consT])) bool) &&
2372-
!rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) &&
2373-
rewriteCondSelectIntoMath(config, addToSub(op.Op), -c.AuxInt) =>
2371+
(CondSelect x op1:(Add8 <t> x c:(Const8 [consT])) bool) &&
2372+
!rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) &&
2373+
rewriteCondSelectIntoMath(config, addToSub(op1.Op), -c.AuxInt) =>
23742374
(Sub8 x (Mul8 <t> (Const8 <t> [-consT]) (CvtBoolToUint8 <t> (Not <bool.Type> bool))))
2375-
(CondSelect x op:(Add(64|32|16) <t> x c:(Const(64|32|16) [consT])) bool) &&
2376-
!rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) &&
2377-
rewriteCondSelectIntoMath(config, addToSub(op.Op), -c.AuxInt) =>
2375+
(CondSelect x op1:(Add(64|32|16) <t> x c:(Const(64|32|16) [consT])) bool) &&
2376+
!rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) &&
2377+
rewriteCondSelectIntoMath(config, addToSub(op1.Op), -c.AuxInt) =>
23782378
(Sub(64|32|16) x (Mul(64|32|16) <t> (Const(64|32|16) <t> [-consT]) (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> (Not <bool.Type> bool)))))
23792379

23802380
// if b { x <<= 1 } => x <<= b
@@ -2390,33 +2390,33 @@
23902390
(CondSelect x (Rsh(64|32|16|8)Ux64 x (Const64 [1])) bool) => (Rsh(64|32|16|8)Ux8 [true] x (CvtBoolToUint8 <types.Types[types.TUINT8]> (Not <bool.Type> bool)))
23912391

23922392
// if b { x |= c } => x |= b * c
2393-
(CondSelect op:(Or8 <t> x c:(Const8)) x bool) &&
2394-
rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) =>
2393+
(CondSelect op1:(Or8 <t> x c:(Const8)) x bool) &&
2394+
rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) =>
23952395
(Or8 x (Mul8 <t> c (CvtBoolToUint8 <t> bool)))
2396-
(CondSelect op:(Or(64|32|16) <t> x c:(Const(64|32|16))) x bool) &&
2397-
rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) =>
2396+
(CondSelect op1:(Or(64|32|16) <t> x c:(Const(64|32|16))) x bool) &&
2397+
rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) =>
23982398
(Or(64|32|16) x (Mul(64|32|16) <t> c (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> bool))))
23992399
// if !b { x |= c } => x |= !b * c
2400-
(CondSelect x op:(Or8 <t> x c:(Const8)) bool) &&
2401-
rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) =>
2400+
(CondSelect x op1:(Or8 <t> x c:(Const8)) bool) &&
2401+
rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) =>
24022402
(Or8 x (Mul8 <t> c (CvtBoolToUint8 <t> (Not <bool.Type> bool))))
2403-
(CondSelect x op:(Or(64|32|16) <t> x c:(Const(64|32|16))) bool) &&
2404-
rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) =>
2403+
(CondSelect x op1:(Or(64|32|16) <t> x c:(Const(64|32|16))) bool) &&
2404+
rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) =>
24052405
(Or(64|32|16) x (Mul(64|32|16) <t> c (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> (Not <bool.Type> bool)))))
24062406

24072407
// if b { x ^= c } => x ^= b * c
2408-
(CondSelect op:(Xor8 <t> x c:(Const8)) x bool) &&
2409-
rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) =>
2408+
(CondSelect op1:(Xor8 <t> x c:(Const8)) x bool) &&
2409+
rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) =>
24102410
(Xor8 x (Mul8 <t> c (CvtBoolToUint8 <t> bool)))
2411-
(CondSelect op:(Xor(64|32|16) <t> x c:(Const(64|32|16))) x bool) &&
2412-
rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) =>
2411+
(CondSelect op1:(Xor(64|32|16) <t> x c:(Const(64|32|16))) x bool) &&
2412+
rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) =>
24132413
(Xor(64|32|16) x (Mul(64|32|16) <t> c (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> bool))))
24142414
// if !b { x ^= c } => x ^= !b * c
2415-
(CondSelect x op:(Xor8 <t> x c:(Const8)) bool) &&
2416-
rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) =>
2415+
(CondSelect x op1:(Xor8 <t> x c:(Const8)) bool) &&
2416+
rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) =>
24172417
(Xor8 x (Mul8 <t> c (CvtBoolToUint8 <t> (Not <bool.Type> bool))))
2418-
(CondSelect x op:(Xor(64|32|16) <t> x c:(Const(64|32|16))) bool) &&
2419-
rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) =>
2418+
(CondSelect x op1:(Xor(64|32|16) <t> x c:(Const(64|32|16))) bool) &&
2419+
rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) =>
24202420
(Xor(64|32|16) x (Mul(64|32|16) <t> c (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> (Not <bool.Type> bool)))))
24212421

24222422
// bool(int(x)) => x

src/cmd/compile/internal/ssa/_gen/rulegen.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ var reservedNames = map[string]bool{
855855
"config": true, // b.Func.Config
856856
"fe": true, // b.Func.fe
857857
"typ": true, // &b.Func.Config.Types
858+
"op": true, // op.OpAMD64MOVBQZX
858859
}
859860

860861
// declf constructs a simple "name := value" declaration,

0 commit comments

Comments
 (0)