diff options
| author | Josh Bleecher Snyder <josharian@gmail.com> | 2019-03-13 13:53:38 -0700 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2019-03-14 00:03:29 +0000 |
| commit | 61945fc5022e36ae88758f2c4e8f7c29f0824ae0 (patch) | |
| tree | e938876dd83eae7b00ae424ad44d3b9f3b817c34 /test/codegen | |
| parent | 2d21bf4252781e3997c30a873e56325436ca3f76 (diff) | |
| download | go-61945fc5022e36ae88758f2c4e8f7c29f0824ae0.tar.xz | |
cmd/compile: don't generate panicshift for masked int shifts
We know that a & 31 is non-negative for all a, signed or not.
We can avoid checking that and needing to write out an
unreachable call to panicshift.
Change-Id: I32f32fb2c950d2b2b35ac5c0e99b7b2dbd47f917
Reviewed-on: https://go-review.googlesource.com/c/go/+/167499
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/codegen')
| -rw-r--r-- | test/codegen/shift.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/codegen/shift.go b/test/codegen/shift.go index 1e145d3748..4ae9d7d6a0 100644 --- a/test/codegen/shift.go +++ b/test/codegen/shift.go @@ -70,6 +70,34 @@ func rshMask64x32Ext(v int64, s int32) int64 { return v >> uint(s&63) } +// --------------- // +// signed shifts // +// --------------- // + +// We do want to generate a test + panicshift for these cases. +func lshSigned(v8 int8, v16 int16, v32 int32, v64 int64, x int) { + // amd64:"TESTB" + _ = x << v8 + // amd64:"TESTW" + _ = x << v16 + // amd64:"TESTL" + _ = x << v32 + // amd64:"TESTQ" + _ = x << v64 +} + +// We want to avoid generating a test + panicshift for these cases. +func lshSignedMasked(v8 int8, v16 int16, v32 int32, v64 int64, x int) { + // amd64:-"TESTB" + _ = x << (v8 & 7) + // amd64:-"TESTW" + _ = x << (v16 & 15) + // amd64:-"TESTL" + _ = x << (v32 & 31) + // amd64:-"TESTQ" + _ = x << (v64 & 63) +} + // ------------------ // // bounded shifts // // ------------------ // |
