From 4cce27a3fa0cc1f13afa6ffa358efa07144e00ec Mon Sep 17 00:00:00 2001 From: Michael Munday Date: Fri, 20 Jan 2017 22:03:13 -0500 Subject: [PATCH] cmd/compile: fix constant propagation through s390x MOVDNE instructions The constant propagation rules selected the wrong operand to propagate. So MOVDNE (move if not equal) propagated operands as if it were a MOVDEQ (move if equal). Fixes #18735. Change-Id: I87ac469172f9df7d5aabaf7106e2936ce54ae202 Reviewed-on: https://go-review.googlesource.com/35498 Run-TryBot: Michael Munday Reviewed-by: Cherry Zhang TryBot-Result: Gobot Gobot --- src/cmd/compile/internal/ssa/gen/S390X.rules | 6 +++--- src/cmd/compile/internal/ssa/rewriteS390X.go | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cmd/compile/internal/ssa/gen/S390X.rules b/src/cmd/compile/internal/ssa/gen/S390X.rules index 3e0533a951..be0d581fe0 100644 --- a/src/cmd/compile/internal/ssa/gen/S390X.rules +++ b/src/cmd/compile/internal/ssa/gen/S390X.rules @@ -885,9 +885,9 @@ (MOVDEQ y _ (FlagLT)) -> y (MOVDEQ y _ (FlagGT)) -> y -(MOVDNE _ y (FlagEQ)) -> y -(MOVDNE x _ (FlagLT)) -> x -(MOVDNE x _ (FlagGT)) -> x +(MOVDNE y _ (FlagEQ)) -> y +(MOVDNE _ x (FlagLT)) -> x +(MOVDNE _ x (FlagGT)) -> x (MOVDLT y _ (FlagEQ)) -> y (MOVDLT _ x (FlagLT)) -> x diff --git a/src/cmd/compile/internal/ssa/rewriteS390X.go b/src/cmd/compile/internal/ssa/rewriteS390X.go index 7d023bcf8b..5acaf2dbdc 100644 --- a/src/cmd/compile/internal/ssa/rewriteS390X.go +++ b/src/cmd/compile/internal/ssa/rewriteS390X.go @@ -9847,11 +9847,11 @@ func rewriteValueS390X_OpS390XMOVDNE(v *Value, config *Config) bool { v.AddArg(cmp) return true } - // match: (MOVDNE _ y (FlagEQ)) + // match: (MOVDNE y _ (FlagEQ)) // cond: // result: y for { - y := v.Args[1] + y := v.Args[0] v_2 := v.Args[2] if v_2.Op != OpS390XFlagEQ { break @@ -9861,11 +9861,11 @@ func rewriteValueS390X_OpS390XMOVDNE(v *Value, config *Config) bool { v.AddArg(y) return true } - // match: (MOVDNE x _ (FlagLT)) + // match: (MOVDNE _ x (FlagLT)) // cond: // result: x for { - x := v.Args[0] + x := v.Args[1] v_2 := v.Args[2] if v_2.Op != OpS390XFlagLT { break @@ -9875,11 +9875,11 @@ func rewriteValueS390X_OpS390XMOVDNE(v *Value, config *Config) bool { v.AddArg(x) return true } - // match: (MOVDNE x _ (FlagGT)) + // match: (MOVDNE _ x (FlagGT)) // cond: // result: x for { - x := v.Args[0] + x := v.Args[1] v_2 := v.Args[2] if v_2.Op != OpS390XFlagGT { break