Skip to content

Commit f422a6f

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 95ed0e3 + a8564bd commit f422a6f

File tree

14 files changed

+655
-52
lines changed

14 files changed

+655
-52
lines changed

src/cmd/compile/internal/riscv64/ssa.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
420420
ssa.OpRISCV64FMVSX, ssa.OpRISCV64FMVXS, ssa.OpRISCV64FMVDX, ssa.OpRISCV64FMVXD,
421421
ssa.OpRISCV64FCVTSW, ssa.OpRISCV64FCVTSL, ssa.OpRISCV64FCVTWS, ssa.OpRISCV64FCVTLS,
422422
ssa.OpRISCV64FCVTDW, ssa.OpRISCV64FCVTDL, ssa.OpRISCV64FCVTWD, ssa.OpRISCV64FCVTLD, ssa.OpRISCV64FCVTDS, ssa.OpRISCV64FCVTSD,
423+
ssa.OpRISCV64FCLASSS, ssa.OpRISCV64FCLASSD,
423424
ssa.OpRISCV64NOT, ssa.OpRISCV64NEG, ssa.OpRISCV64NEGW, ssa.OpRISCV64CLZ, ssa.OpRISCV64CLZW, ssa.OpRISCV64CTZ, ssa.OpRISCV64CTZW,
424425
ssa.OpRISCV64REV8, ssa.OpRISCV64CPOP, ssa.OpRISCV64CPOPW:
425426
p := s.Prog(v.Op.Asm())

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,18 @@
862862
(F(MADD|NMADD|MSUB|NMSUB)D neg:(FNEGD x) y z) && neg.Uses == 1 => (F(NMSUB|MSUB|NMADD|MADD)D x y z)
863863
(F(MADD|NMADD|MSUB|NMSUB)D x y neg:(FNEGD z)) && neg.Uses == 1 => (F(MSUB|NMSUB|MADD|NMADD)D x y z)
864864

865+
// Test for -∞ (bit 0) using 64 bit classify instruction.
866+
(FLTD x (FMVDX (MOVDconst [int64(math.Float64bits(-math.MaxFloat64))]))) => (ANDI [1] (FCLASSD x))
867+
(FLED (FMVDX (MOVDconst [int64(math.Float64bits(-math.MaxFloat64))])) x) => (SNEZ (ANDI <typ.Int64> [0xff &^ 1] (FCLASSD x)))
868+
(FEQD x (FMVDX (MOVDconst [int64(math.Float64bits(math.Inf(-1)))]))) => (ANDI [1] (FCLASSD x))
869+
(FNED x (FMVDX (MOVDconst [int64(math.Float64bits(math.Inf(-1)))]))) => (SEQZ (ANDI <typ.Int64> [1] (FCLASSD x)))
870+
871+
// Test for +∞ (bit 7) using 64 bit classify instruction.
872+
(FLTD (FMVDX (MOVDconst [int64(math.Float64bits(math.MaxFloat64))])) x) => (SNEZ (ANDI <typ.Int64> [1<<7] (FCLASSD x)))
873+
(FLED x (FMVDX (MOVDconst [int64(math.Float64bits(math.MaxFloat64))]))) => (SNEZ (ANDI <typ.Int64> [0xff &^ (1<<7)] (FCLASSD x)))
874+
(FEQD x (FMVDX (MOVDconst [int64(math.Float64bits(math.Inf(1)))]))) => (SNEZ (ANDI <typ.Int64> [1<<7] (FCLASSD x)))
875+
(FNED x (FMVDX (MOVDconst [int64(math.Float64bits(math.Inf(1)))]))) => (SEQZ (ANDI <typ.Int64> [1<<7] (FCLASSD x)))
876+
865877
//
866878
// Optimisations for rva22u64 and above.
867879
//

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,27 @@ func init() {
497497
{name: "FLED", argLength: 2, reg: fp2gp, asm: "FLED"}, // arg0 <= arg1
498498
{name: "LoweredFMIND", argLength: 2, reg: fp21, resultNotInArgs: true, asm: "FMIND", commutative: true, typ: "Float64"}, // min(arg0, arg1)
499499
{name: "LoweredFMAXD", argLength: 2, reg: fp21, resultNotInArgs: true, asm: "FMAXD", commutative: true, typ: "Float64"}, // max(arg0, arg1)
500+
501+
// Floating point classify (in the F and D extensions).
502+
//
503+
// The FCLASS instructions will always set exactly one bit in the output
504+
// register, all other bits will be cleared.
505+
//
506+
// Bit | Class
507+
// ====+=============================
508+
// 0 | -∞
509+
// 1 | a negative normal number
510+
// 2 | a negative subnormal number
511+
// 3 | -0
512+
// 4 | +0
513+
// 5 | a positive subnormal number
514+
// 6 | a positive normal number
515+
// 7 | +∞
516+
// 8 | qNaN
517+
// 9 | sNaN
518+
// ====+=============================
519+
{name: "FCLASSS", argLength: 1, reg: fpgp, asm: "FCLASSS", typ: "Int64"}, // classify float32
520+
{name: "FCLASSD", argLength: 1, reg: fpgp, asm: "FCLASSD", typ: "Int64"}, // classify float64
500521
}
501522

502523
RISCV64blocks := []blockData{

src/cmd/compile/internal/ssa/opGen.go

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/compile/internal/ssa/rewriteRISCV64.go

Lines changed: 204 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)