-
Notifications
You must be signed in to change notification settings - Fork 2.7k
IsSupported returns false for not-fully-implemented ISA classes #15514
Conversation
@jkotas @CarolEidt @BruceForstall My current solution is to add a new environment variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the new config variable is a good approach, but would like to see it enabled only under DEBUG (i.e. Debug or Checked builds).
src/jit/hwintrinsicxarch.cpp
Outdated
case InstructionSet_FMA: | ||
case InstructionSet_PCLMULQDQ: | ||
// DONE - InstructionSet_LZCNT: | ||
// DONE - InstructionSet_POPCNT: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to see explicit cases for the ones that are done, and then the default
should be unreached()
.
src/jit/hwintrinsicxarch.cpp
Outdated
if ((!compSupports(isa) || (!featureSIMD && isa != InstructionSet_BMI1 && isa != InstructionSet_BMI2 && | ||
isa != InstructionSet_LZCNT && isa != InstructionSet_POPCNT)) && | ||
// - the ISA class is not yet fully implemented and EnableIncompleteISAClass=false | ||
if ((!compSupports(isa) || (!JitConfig.EnableIncompleteISAClass() && !isFullyImplmentedISAClass(isa)) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cleaner to have this check look something like this:
if ((!compSupports(isa) || !compSupportsIntrinsics(isa)) && !isIntrinsicAnIsSupportedPropertyGetter(intrinsic))
Then, compSupportsIntrinsics(isa)
can incorporate both the check for those that are fully supported, as well as, under DEBUG
only, checking JitConfig.EnableIncompleteISAClass()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be more elegant. Will change.
src/jit/hwintrinsicxarch.cpp
Outdated
@@ -186,6 +186,33 @@ bool Compiler::isIntrinsicAnIsSupportedPropertyGetter(NamedIntrinsic intrinsic) | |||
} | |||
} | |||
|
|||
// TODO - remove the fully implemented ISA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that all these TODO
comments should be omitted. I expect that it will take some time to complete the current set of ISAs, and there are likely to be more in future.
@CarolEidt I remember we talked this issue in that email thread. @jkotas mentioned that inconsistent behavior between release and debug build will make some test problems. |
@jkotas @BruceForstall comments? |
Without any environment variable, the debug and release need to behave the same. It is fine for the environment variable to be respected in debug build only. Debug and release can behave differently with environment variable set. |
Got it, thank you! |
Moved |
src/jit/compiler.h
Outdated
@@ -3044,6 +3044,7 @@ class Compiler | |||
GenTree* impLZCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); | |||
GenTree* impPCLMULQDQIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); | |||
GenTree* impPOPCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig); | |||
bool compSupportHWIntrinsic(InstructionSet isa); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be compSupportsHWIntrinsic
src/jit/hwintrinsicxarch.cpp
Outdated
// TODO - remove "JitConfig.EnableIncompleteISAClass()" after fully implement hardware intrinsics of this | ||
// class | ||
retNode = | ||
gtNewIconNode(JitConfig.EnableIncompleteISAClass() && featureSIMD && compSupports(InstructionSet_SSE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this test redundant with the one above? The check for JitConfig.EnableIncompleteISAClass()
can only be done under DEBUG
, but I believe that this check is redundant anyway, unless there's something I've missed.
Also, I still think these "TODO" comments are unnecessary, as I believe that we will need that facility for some time as new ISA feature sets are added and implemented over time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this test redundant with the one above?
No, this check lets IsSupported
return false
for incomplete classes, but the above one lets intrinsics throw PNSE when the call site is not guarded by IsSupported
.
The check for JitConfig.EnableIncompleteISAClass() can only be done under DEBUG,
Oops, my mistake. Will fix.
src/jit/hwintrinsicxarch.cpp
Outdated
isa != InstructionSet_LZCNT && isa != InstructionSet_POPCNT)) && | ||
!isIntrinsicAnIsSupportedPropertyGetter(intrinsic)) | ||
// - JIT does not support this hardware intrinsics (compSupportHWIntrinsic return false) | ||
if ((!compSupports(isa) || !compSupportHWIntrinsic(isa)) && !isIntrinsicAnIsSupportedPropertyGetter(intrinsic)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you extract the check for the specific ISA intrinsics at the beginning, e.g.
bool supported = (featureSIMD && compSupports(isa) && compSupportsHWIntrinsics(isa));
Then, the above check can be:
if (!supported && !isIntrinsicAnIsSupportedPropertyGetter(intrinsic))
and the checks below can be:
retNode = gtNewIconNode(supported);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, will do.
Streamlined IsSupported code. @CarolEidt @jkotas PTAL |
src/jit/hwintrinsicxarch.cpp
Outdated
@@ -186,6 +186,49 @@ bool Compiler::isIntrinsicAnIsSupportedPropertyGetter(NamedIntrinsic intrinsic) | |||
} | |||
} | |||
|
|||
bool isFullyImplmentedISAClass(InstructionSet isa) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function needs a standard header comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please make this a (static) member of the Compiler class.
src/jit/hwintrinsicxarch.cpp
Outdated
} | ||
} | ||
|
||
// return true if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a standard header comment format
src/jit/hwintrinsicxarch.cpp
Outdated
// - isa is fully implemented or EnableIncompleteISAClass=true | ||
bool Compiler::compSupportsHWIntrinsic(InstructionSet isa) | ||
{ | ||
return (featureSIMD || isa == InstructionSet_BMI1 || isa == InstructionSet_BMI2 || isa == InstructionSet_LZCNT || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you should add a:
bool Compiler::compIsScalarISA(InstructionSet isa)
{
return (isa == InstructionSet_BMI1) || (isa == InstructionSet_BMI2) || (isa == InstructionSet_LZCNT) || (isa == InstructionSet_POPCNT);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, will change.
f94a3c9
to
58ba214
Compare
@BruceForstall addressed feedback. PTAL. |
FYI @eerhardt |
@dotnet-bot test Windows_NT x86 Checked Innerloop Build and Test |
@CarolEidt @BruceForstall ping? |
Resolve #14930