Skip to content

Commit 5b921e2

Browse files
authored
JIT: Model GetFfr* with a special side effect and handle it in VN (#105973)
- Add `HW_Flag_SpecialSideEffect_Other` to GetFfr* HW intrinsics. These intrinsics essentially read memory from memory that we do not model, so we have to treat them conservatively. - Add `GTF_CALL` and `GTF_GLOB_REF` to `GetFfr*` HW intrinsics. We have to give these a conservative set of a flag to disallow the rest of the JIT from potentially reordering them with `SetFfr`. - Teach VN to give all HW intrinsics with any special side effect a unique VN Fix #105944 In the test case head-merging reorders a `SetFfr` with a `GetFfr` since `GetFfr` is not given appropriately conservative side effect flags: ``` *************** Starting PHASE Head and tail merge Both succs of BB01 start with the same tree STMT00006 ( 0x02F[E-] ... 0x03C ) [000039] --C-G------ * HWINTRINSIC void ubyte SetFfr [000037] ----------- \--* HWINTRINSIC mask ubyte CreateTrueMaskByte [000036] ----------- \--* CNS_INT int 31 Checking if we can move it into the predecessor... We can; moving statement unlinking STMT00006 ( 0x02F[E-] ... 0x03C ) [000039] --C-G------ * HWINTRINSIC void ubyte SetFfr [000037] ----------- \--* HWINTRINSIC mask ubyte CreateTrueMaskByte [000036] ----------- \--* CNS_INT int 31 from BB02 unlinking STMT00004 ( 0x03D[E-] ... 0x04A ) [000031] --C-G------ * HWINTRINSIC void ubyte SetFfr [000029] ----------- \--* HWINTRINSIC mask ubyte CreateTrueMaskByte [000028] ----------- \--* CNS_INT int 31 from BB03 Did 1 head merges in BB01 ... ------------ BB01 [0000] [000..02F) -> BB03(0.5),BB02(0.5) (cond), preds={} succs={BB02,BB03} ***** BB01 [0000] STMT00000 ( 0x000[E-] ... 0x01B ) [000003] --C-G------ * HWINTRINSIC void ubyte SetFfr [000001] ----------- \--* HWINTRINSIC mask ubyte CreateTrueMaskByte [000000] ----------- \--* CNS_INT int 31 ***** BB01 [0000] STMT00001 ( 0x00C[E-] ... ??? ) [000016] DA-XG------ * STORE_LCL_VAR simd16 V02 tmp1 [000013] ---XG------ \--* HWINTRINSIC simd16 ubyte LoadVectorFirstFaulting [000015] ----------- +--* HWINTRINSIC mask ubyte ConvertVectorToMask [000014] ----------- | +--* HWINTRINSIC mask ubyte CreateTrueMaskAll [000008] ----------- | \--* HWINTRINSIC simd16 ubyte ConvertMaskToVector [000007] ----------- | \--* HWINTRINSIC mask ubyte CreateTrueMaskByte [000006] ----------- | \--* CNS_INT int 31 [000012] ----------- \--* ADD long [000009] ----------- +--* LCL_VAR long V00 arg0 [000011] ----------- \--* CAST long <- int [000010] ----------- \--* CNS_INT int 1 ***** BB01 [0000] STMT00002 ( ??? ... ??? ) [000018] ----------- * NOP void ***** BB01 [0000] STMT00006 ( 0x02F[E-] ... 0x03C ) [000039] --C-G------ * HWINTRINSIC void ubyte SetFfr ; head-merging moved this from the then/else blocks [000037] ----------- \--* HWINTRINSIC mask ubyte CreateTrueMaskByte [000036] ----------- \--* CNS_INT int 31 ***** BB01 [0000] STMT00003 ( 0x01C[E-] ... 0x02D ) [000027] ----------- * JTRUE void [000026] ----------- \--* EQ int [000024] ----------- +--* HWINTRINSIC int ubyte op_Equality [000020] ----------- | +--* HWINTRINSIC simd16 ubyte ConvertMaskToVector [000019] ----------- | | \--* HWINTRINSIC mask ubyte GetFfrByte [000023] ----------- | \--* HWINTRINSIC simd16 ubyte ConvertMaskToVector [000022] ----------- | \--* HWINTRINSIC mask ubyte CreateTrueMaskByte [000021] ----------- | \--* CNS_INT int 31 [000025] ----------- \--* CNS_INT int 0 ```
1 parent bcca12c commit 5b921e2

File tree

6 files changed

+98
-12
lines changed

6 files changed

+98
-12
lines changed

src/coreclr/jit/fgdiagnostic.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3436,6 +3436,14 @@ void Compiler::fgDebugCheckFlags(GenTree* tree, BasicBlock* block)
34363436
case NI_Sve_PrefetchInt16:
34373437
case NI_Sve_PrefetchInt32:
34383438
case NI_Sve_PrefetchInt64:
3439+
case NI_Sve_GetFfrByte:
3440+
case NI_Sve_GetFfrInt16:
3441+
case NI_Sve_GetFfrInt32:
3442+
case NI_Sve_GetFfrInt64:
3443+
case NI_Sve_GetFfrSByte:
3444+
case NI_Sve_GetFfrUInt16:
3445+
case NI_Sve_GetFfrUInt32:
3446+
case NI_Sve_GetFfrUInt64:
34393447
case NI_Sve_SetFfr:
34403448
{
34413449
assert(tree->OperRequiresCallFlag(this));

src/coreclr/jit/gentree.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27268,6 +27268,14 @@ bool GenTreeHWIntrinsic::OperRequiresCallFlag() const
2726827268
case NI_Sve_GatherPrefetch32Bit:
2726927269
case NI_Sve_GatherPrefetch64Bit:
2727027270
case NI_Sve_GatherPrefetch8Bit:
27271+
case NI_Sve_GetFfrByte:
27272+
case NI_Sve_GetFfrInt16:
27273+
case NI_Sve_GetFfrInt32:
27274+
case NI_Sve_GetFfrInt64:
27275+
case NI_Sve_GetFfrSByte:
27276+
case NI_Sve_GetFfrUInt16:
27277+
case NI_Sve_GetFfrUInt32:
27278+
case NI_Sve_GetFfrUInt64:
2727127279
case NI_Sve_SetFfr:
2727227280
{
2727327281
return true;
@@ -27459,6 +27467,14 @@ void GenTreeHWIntrinsic::Initialize(NamedIntrinsic intrinsicId)
2745927467
case NI_Sve_PrefetchInt16:
2746027468
case NI_Sve_PrefetchInt32:
2746127469
case NI_Sve_PrefetchInt64:
27470+
case NI_Sve_GetFfrByte:
27471+
case NI_Sve_GetFfrInt16:
27472+
case NI_Sve_GetFfrInt32:
27473+
case NI_Sve_GetFfrInt64:
27474+
case NI_Sve_GetFfrSByte:
27475+
case NI_Sve_GetFfrUInt16:
27476+
case NI_Sve_GetFfrUInt32:
27477+
case NI_Sve_GetFfrUInt64:
2746227478
case NI_Sve_SetFfr:
2746327479
{
2746427480
// Mark as a call and global reference, much as is done for GT_KEEPALIVE

0 commit comments

Comments
 (0)