Skip to content

Commit b20540d

Browse files
karolmikolajczukigcbot
authored andcommitted
Changes in code.
1 parent 50311f7 commit b20540d

File tree

2 files changed

+4
-145
lines changed

2 files changed

+4
-145
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 4 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,70 +1766,6 @@ namespace IGC
17661766

17671767
void CEncoder::Arithmetic(ISA_Opcode opcode, CVariable* dst, CVariable* src0, CVariable* src1, CVariable* src2)
17681768
{
1769-
// Single Precision or Double precision denorm mode in
1770-
// control register must be set to retain denorm mode
1771-
// when executing Math Macro instruction sequence.
1772-
// It applies to the platforms which has correctly implemented
1773-
// macros and INV and SQRT instructions.
1774-
// 1. Set appropriate bit in control register.
1775-
// 2. Execute inv or sqrt instruction
1776-
// 3. Flush denorm in the result if flushing was enabled.
1777-
// 4. Restore original denorm mode in control register.
1778-
bool forceRetainDenorms =
1779-
m_program->m_Platform->hasCorrectlyRoundedMacros() &&
1780-
((opcode == ISA_Opcode::ISA_INV) || (opcode == ISA_Opcode::ISA_SQRT)) &&
1781-
IsFloat(src0->GetType()) &&
1782-
(src1 == nullptr);
1783-
1784-
// Save original denorm mode. This value is a mask of bits
1785-
// corresponding to the denorm bits in Control register.
1786-
uint32_t oldDenormMode = m_fpDenormMode;
1787-
1788-
if (forceRetainDenorms)
1789-
{
1790-
IGC_ASSERT_MESSAGE(src1 == nullptr, "Unsupported opcode for Forcing Retain Denorm Mode.");
1791-
1792-
DenormModeEncoding denormMode = DenormModeEncoding::DenormFlushToZero;
1793-
1794-
// Check the type of src0, currently the restrictions applied only
1795-
// to unary instructions.
1796-
// Get the denorm mode mask for that data type.
1797-
switch (src0->GetType())
1798-
{
1799-
case ISA_TYPE_DF:
1800-
denormMode = DenormModeEncoding::Float64DenormRetain;
1801-
break;
1802-
1803-
case ISA_TYPE_F:
1804-
denormMode = DenormModeEncoding::Float32DenormRetain;
1805-
break;
1806-
1807-
case ISA_TYPE_HF:
1808-
denormMode = DenormModeEncoding::Float16DenormRetain;
1809-
break;
1810-
1811-
case ISA_TYPE_BF:
1812-
denormMode = DenormModeEncoding::FloatBFTFDenormRetain;
1813-
break;
1814-
1815-
default:
1816-
IGC_ASSERT_MESSAGE(0, "Incorrect Float type.");
1817-
}
1818-
1819-
// Check if the original denorm mode for the src0 data type
1820-
// was 0 (flush to zero).
1821-
// denormMode will always have a bit set for the given data
1822-
// type. If currently set mode is 0 (flush to zero), the
1823-
// ANDing these values will give 0, thus cr must be temporarily
1824-
// updated and flushing the destination must be added,
1825-
forceRetainDenorms &= (m_fpDenormMode && denormMode) == 0;
1826-
1827-
if (forceRetainDenorms)
1828-
{
1829-
SetDenormMode(denormMode);
1830-
}
1831-
}
1832-
18331769
VISA_VectorOpnd* srcOpnd0 = GetSourceOperand(src0, m_encoderState.m_srcOperand[0]);
18341770
VISA_VectorOpnd* srcOpnd1 = GetSourceOperand(src1, m_encoderState.m_srcOperand[1]);
18351771
VISA_VectorOpnd* srcOpnd2 = GetSourceOperand(src2, m_encoderState.m_srcOperand[2]);
@@ -1845,17 +1781,6 @@ namespace IGC
18451781
srcOpnd0,
18461782
srcOpnd1,
18471783
srcOpnd2));
1848-
1849-
if (forceRetainDenorms)
1850-
{
1851-
// Restore the original denorm mode.
1852-
SetDenormMode(oldDenormMode);
1853-
1854-
// Force flushing the destination to zero by adding -0 to it.
1855-
CVariable* negativeZero = m_program->ImmToVariable((uint64_t)-0.0, dst->GetType());
1856-
Add(dst, dst, negativeZero);
1857-
}
1858-
18591784
}
18601785

18611786
void CEncoder::Bfn(uint8_t booleanFuncCtrl, CVariable* dst, CVariable* src0, CVariable* src1, CVariable* src2)
@@ -2939,17 +2864,13 @@ namespace IGC
29392864

29402865
CodeGenContext* pCtx = m_program->GetContext();
29412866
if (pCtx->m_floatDenormMode16 == FLOAT_DENORM_RETAIN)
2942-
imm_data |= DenormModeEncoding::Float16DenormRetain;
2867+
imm_data |= 0x400;
29432868
if (pCtx->m_floatDenormMode32 == FLOAT_DENORM_RETAIN)
2944-
imm_data |= DenormModeEncoding::Float32DenormRetain;
2869+
imm_data |= 0x80;
29452870
if (pCtx->m_floatDenormMode64 == FLOAT_DENORM_RETAIN)
2946-
imm_data |= DenormModeEncoding::Float64DenormRetain;
2871+
imm_data |= 0x40;
29472872
if (pCtx->m_floatDenormModeBFTF == FLOAT_DENORM_RETAIN)
2948-
imm_data |= DenormModeEncoding::FloatBFTFDenormRetain;
2949-
2950-
// Store current denorm mode in the encoder for easier handling
2951-
// its temporary changes.
2952-
m_fpDenormMode = imm_data;
2873+
imm_data |= (0x1 << 30);
29532874

29542875
uint RM_bits = 0;
29552876
ERoundingMode RM_FPCvtInt = static_cast<ERoundingMode>(pCtx->getModuleMetaData()->compOpt.FloatCvtIntRoundingMode);
@@ -3017,51 +2938,6 @@ namespace IGC
30172938
src1_Opnd));
30182939
}
30192940

3020-
// Update denorm mode in CR0 register.
3021-
// Set only the 4 bits controlling the state of denorm
3022-
// handling.
3023-
void CEncoder::SetDenormMode(uint32_t newDenormMode)
3024-
{
3025-
// Do not update if current denorm state is the same
3026-
// as a target one.
3027-
if ((m_fpDenormMode && newDenormMode) != 0)
3028-
{
3029-
return;
3030-
}
3031-
3032-
VISA_VectorOpnd* src0_Opnd = nullptr;
3033-
VISA_VectorOpnd* src1_Opnd = nullptr;
3034-
VISA_VectorOpnd* dst_Opnd = nullptr;
3035-
VISA_GenVar* cr0_var = nullptr;
3036-
3037-
// Prepare data for the update.
3038-
// Xor current denorm mode with a new mode.
3039-
// The result will be xored with the CR register.
3040-
// This way CR will be updated only on bits related to
3041-
// denorm mode.
3042-
// To keep m_fpDenormMode in sync with CR0, xor it
3043-
// also with the same value CR0 will be xored with.
3044-
uint32_t value = m_fpDenormMode ^ newDenormMode;
3045-
m_fpDenormMode = m_fpDenormMode ^ value;
3046-
3047-
IGC_ASSERT(nullptr != vKernel);
3048-
3049-
V(vKernel->GetPredefinedVar(cr0_var, PREDEFINED_CR0));
3050-
V(vKernel->CreateVISASrcOperand(src0_Opnd, cr0_var, MODIFIER_NONE, 0, 1, 0, 0, 0));
3051-
V(vKernel->CreateVISAImmediate(src1_Opnd, &value, ISA_TYPE_UD));
3052-
V(vKernel->CreateVISADstOperand(dst_Opnd, cr0_var, 1, 0, 0));
3053-
3054-
V(vKernel->AppendVISAArithmeticInst(
3055-
ISA_XOR,
3056-
nullptr,
3057-
false,
3058-
vISA_EMASK_M1_NM,
3059-
EXEC_SIZE_1,
3060-
dst_Opnd,
3061-
src0_Opnd,
3062-
src1_Opnd));
3063-
}
3064-
30652941
void CEncoder::SetRoundingMode_FP(ERoundingMode actualRM, ERoundingMode newRM)
30662942
{
30672943
IGC_ASSERT_MESSAGE(newRM != ERoundingMode::ROUND_TO_ANY, "Invalid rounding mode");

IGC/Compiler/CISACodeGen/CISABuilder.hpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -686,20 +686,6 @@ namespace IGC
686686
return ExecSize == EXEC_SIZE_16;
687687
}
688688

689-
// Denorm mode bits in CR0.0.
690-
// Define the values which can be used to set
691-
// denorm mode for 4 float data types.
692-
enum DenormModeEncoding : uint32_t
693-
{
694-
Float16DenormRetain = 0x400,
695-
Float32DenormRetain = 0x80,
696-
Float64DenormRetain = 0x40,
697-
FloatBFTFDenormRetain = 0x40000000,
698-
DenormFlushToZero = 0x0,
699-
};
700-
701-
void SetDenormMode(uint32_t newDenormMode);
702-
703689
// Note that GEN can set both fpCvtInt_rtz and any of FP rounding modes
704690
// at the same time. If fpCvtInt uses a rounding mode other than rtz,
705691
// they both uses FP rounding bits.
@@ -792,9 +778,6 @@ namespace IGC
792778
// only to certain APIs/shader types/reg key settings/etc.
793779
WA_TABLE m_vISAWaTable = {};
794780

795-
// Keeps current state of denorm mode set in cr0 register.
796-
uint32_t m_fpDenormMode{};
797-
798781
enum OpType
799782
{
800783
ET_BOOL,

0 commit comments

Comments
 (0)