Skip to content

Commit f54e0bf

Browse files
Theo Weidmanneme64
authored andcommitted
8345766: C2 should emit macro nodes for ModF/ModD instead of calls during parsing
Reviewed-by: kvn, epeter
1 parent 0f426e4 commit f54e0bf

File tree

11 files changed

+423
-270
lines changed

11 files changed

+423
-270
lines changed

src/hotspot/cpu/x86/x86_32.ad

Lines changed: 1 addition & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
33
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
//
55
// This code is free software; you can redistribute it and/or modify it
@@ -2443,22 +2443,6 @@ encode %{
24432443
}
24442444
%}
24452445

2446-
enc_class Push_ModD_encoding(regD src0, regD src1) %{
2447-
__ subptr(rsp, 8);
2448-
__ movdbl(Address(rsp, 0), $src1$$XMMRegister);
2449-
__ fld_d(Address(rsp, 0));
2450-
__ movdbl(Address(rsp, 0), $src0$$XMMRegister);
2451-
__ fld_d(Address(rsp, 0));
2452-
%}
2453-
2454-
enc_class Push_ModF_encoding(regF src0, regF src1) %{
2455-
__ subptr(rsp, 4);
2456-
__ movflt(Address(rsp, 0), $src1$$XMMRegister);
2457-
__ fld_s(Address(rsp, 0));
2458-
__ movflt(Address(rsp, 0), $src0$$XMMRegister);
2459-
__ fld_s(Address(rsp, 0));
2460-
%}
2461-
24622446
enc_class Push_ResultD(regD dst) %{
24632447
__ fstp_d(Address(rsp, 0));
24642448
__ movdbl($dst$$XMMRegister, Address(rsp, 0));
@@ -2490,20 +2474,6 @@ encode %{
24902474
__ fld_d(Address(rsp, 0));
24912475
%}
24922476

2493-
enc_class Push_Result_Mod_DPR( regDPR src) %{
2494-
if ($src$$reg != FPR1L_enc) {
2495-
// fincstp
2496-
emit_opcode (masm, 0xD9);
2497-
emit_opcode (masm, 0xF7);
2498-
// FXCH FPR1 with src
2499-
emit_opcode(masm, 0xD9);
2500-
emit_d8(masm, 0xC8-1+$src$$reg );
2501-
// fdecstp
2502-
emit_opcode (masm, 0xD9);
2503-
emit_opcode (masm, 0xF6);
2504-
}
2505-
%}
2506-
25072477
enc_class fnstsw_sahf_skip_parity() %{
25082478
// fnstsw ax
25092479
emit_opcode( masm, 0xDF );
@@ -2515,28 +2485,6 @@ encode %{
25152485
emit_opcode( masm, 0x05 );
25162486
%}
25172487

2518-
enc_class emitModDPR() %{
2519-
// fprem must be iterative
2520-
// :: loop
2521-
// fprem
2522-
emit_opcode( masm, 0xD9 );
2523-
emit_opcode( masm, 0xF8 );
2524-
// wait
2525-
emit_opcode( masm, 0x9b );
2526-
// fnstsw ax
2527-
emit_opcode( masm, 0xDF );
2528-
emit_opcode( masm, 0xE0 );
2529-
// sahf
2530-
emit_opcode( masm, 0x9E );
2531-
// jp ::loop
2532-
emit_opcode( masm, 0x0F );
2533-
emit_opcode( masm, 0x8A );
2534-
emit_opcode( masm, 0xF4 );
2535-
emit_opcode( masm, 0xFF );
2536-
emit_opcode( masm, 0xFF );
2537-
emit_opcode( masm, 0xFF );
2538-
%}
2539-
25402488
enc_class fpu_flags() %{
25412489
// fnstsw_ax
25422490
emit_opcode( masm, 0xDF);
@@ -9801,45 +9749,6 @@ instruct strictfp_divDPR_reg(regDPR1 dst, regnotDPR1 src) %{
98019749
ins_pipe( fpu_reg_reg );
98029750
%}
98039751

9804-
instruct modDPR_reg(regDPR dst, regDPR src, eAXRegI rax, eFlagsReg cr) %{
9805-
predicate(UseSSE<=1);
9806-
match(Set dst (ModD dst src));
9807-
effect(KILL rax, KILL cr); // emitModDPR() uses EAX and EFLAGS
9808-
9809-
format %{ "DMOD $dst,$src" %}
9810-
ins_cost(250);
9811-
ins_encode(Push_Reg_Mod_DPR(dst, src),
9812-
emitModDPR(),
9813-
Push_Result_Mod_DPR(src),
9814-
Pop_Reg_DPR(dst));
9815-
ins_pipe( pipe_slow );
9816-
%}
9817-
9818-
instruct modD_reg(regD dst, regD src0, regD src1, eAXRegI rax, eFlagsReg cr) %{
9819-
predicate(UseSSE>=2);
9820-
match(Set dst (ModD src0 src1));
9821-
effect(KILL rax, KILL cr);
9822-
9823-
format %{ "SUB ESP,8\t # DMOD\n"
9824-
"\tMOVSD [ESP+0],$src1\n"
9825-
"\tFLD_D [ESP+0]\n"
9826-
"\tMOVSD [ESP+0],$src0\n"
9827-
"\tFLD_D [ESP+0]\n"
9828-
"loop:\tFPREM\n"
9829-
"\tFWAIT\n"
9830-
"\tFNSTSW AX\n"
9831-
"\tSAHF\n"
9832-
"\tJP loop\n"
9833-
"\tFSTP_D [ESP+0]\n"
9834-
"\tMOVSD $dst,[ESP+0]\n"
9835-
"\tADD ESP,8\n"
9836-
"\tFSTP ST0\t # Restore FPU Stack"
9837-
%}
9838-
ins_cost(250);
9839-
ins_encode( Push_ModD_encoding(src0, src1), emitModDPR(), Push_ResultD(dst), PopFPU);
9840-
ins_pipe( pipe_slow );
9841-
%}
9842-
98439752
instruct atanDPR_reg(regDPR dst, regDPR src) %{
98449753
predicate (UseSSE<=1);
98459754
match(Set dst(AtanD dst src));
@@ -10445,59 +10354,6 @@ instruct divFPR_reg(regFPR dst, regFPR src) %{
1044510354
%}
1044610355

1044710356

10448-
// Spill to obtain 24-bit precision
10449-
instruct modFPR24_reg(stackSlotF dst, regFPR src1, regFPR src2, eAXRegI rax, eFlagsReg cr) %{
10450-
predicate( UseSSE==0 && Compile::current()->select_24_bit_instr());
10451-
match(Set dst (ModF src1 src2));
10452-
effect(KILL rax, KILL cr); // emitModDPR() uses EAX and EFLAGS
10453-
10454-
format %{ "FMOD $dst,$src1,$src2" %}
10455-
ins_encode( Push_Reg_Mod_DPR(src1, src2),
10456-
emitModDPR(),
10457-
Push_Result_Mod_DPR(src2),
10458-
Pop_Mem_FPR(dst));
10459-
ins_pipe( pipe_slow );
10460-
%}
10461-
//
10462-
// This instruction does not round to 24-bits
10463-
instruct modFPR_reg(regFPR dst, regFPR src, eAXRegI rax, eFlagsReg cr) %{
10464-
predicate( UseSSE==0 && !Compile::current()->select_24_bit_instr());
10465-
match(Set dst (ModF dst src));
10466-
effect(KILL rax, KILL cr); // emitModDPR() uses EAX and EFLAGS
10467-
10468-
format %{ "FMOD $dst,$src" %}
10469-
ins_encode(Push_Reg_Mod_DPR(dst, src),
10470-
emitModDPR(),
10471-
Push_Result_Mod_DPR(src),
10472-
Pop_Reg_FPR(dst));
10473-
ins_pipe( pipe_slow );
10474-
%}
10475-
10476-
instruct modF_reg(regF dst, regF src0, regF src1, eAXRegI rax, eFlagsReg cr) %{
10477-
predicate(UseSSE>=1);
10478-
match(Set dst (ModF src0 src1));
10479-
effect(KILL rax, KILL cr);
10480-
format %{ "SUB ESP,4\t # FMOD\n"
10481-
"\tMOVSS [ESP+0],$src1\n"
10482-
"\tFLD_S [ESP+0]\n"
10483-
"\tMOVSS [ESP+0],$src0\n"
10484-
"\tFLD_S [ESP+0]\n"
10485-
"loop:\tFPREM\n"
10486-
"\tFWAIT\n"
10487-
"\tFNSTSW AX\n"
10488-
"\tSAHF\n"
10489-
"\tJP loop\n"
10490-
"\tFSTP_S [ESP+0]\n"
10491-
"\tMOVSS $dst,[ESP+0]\n"
10492-
"\tADD ESP,4\n"
10493-
"\tFSTP ST0\t # Restore FPU Stack"
10494-
%}
10495-
ins_cost(250);
10496-
ins_encode( Push_ModF_encoding(src0, src1), emitModDPR(), Push_ResultF(dst,0x4), PopFPU);
10497-
ins_pipe( pipe_slow );
10498-
%}
10499-
10500-
1050110357
//----------Arithmetic Conversion Instructions---------------------------------
1050210358
// The conversions operations are all Alpha sorted. Please keep it that way!
1050310359

src/hotspot/share/opto/callnode.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,9 @@ void CallNode::dump_spec(outputStream *st) const {
718718

719719
const Type *CallNode::bottom_type() const { return tf()->range(); }
720720
const Type* CallNode::Value(PhaseGVN* phase) const {
721-
if (phase->type(in(0)) == Type::TOP) return Type::TOP;
721+
if (in(0) == nullptr || phase->type(in(0)) == Type::TOP) {
722+
return Type::TOP;
723+
}
722724
return tf()->range();
723725
}
724726

0 commit comments

Comments
 (0)