IsSupported returns false for not-fully-implemented ISA classes#15514
Conversation
|
@jkotas @CarolEidt @BruceForstall My current solution is to add a new environment variable |
CarolEidt
left a comment
There was a problem hiding this comment.
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).
| case InstructionSet_FMA: | ||
| case InstructionSet_PCLMULQDQ: | ||
| // DONE - InstructionSet_LZCNT: | ||
| // DONE - InstructionSet_POPCNT: |
There was a problem hiding this comment.
I would prefer to see explicit cases for the ones that are done, and then the default should be unreached().
| 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.
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.
That would be more elegant. Will change.
| } | ||
| } | ||
|
|
||
| // TODO - remove the fully implemented ISA |
There was a problem hiding this comment.
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 |
| 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.
This should be compSupportsHWIntrinsic
| // 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.
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.
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.
| 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.
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);
|
Streamlined IsSupported code. @CarolEidt @jkotas PTAL |
| } | ||
| } | ||
|
|
||
| bool isFullyImplmentedISAClass(InstructionSet isa) |
There was a problem hiding this comment.
This function needs a standard header comment
There was a problem hiding this comment.
Also, please make this a (static) member of the Compiler class.
| } | ||
| } | ||
|
|
||
| // return true if |
There was a problem hiding this comment.
Please use a standard header comment format
| // - 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.
Looks like you should add a:
bool Compiler::compIsScalarISA(InstructionSet isa)
{
return (isa == InstructionSet_BMI1) || (isa == InstructionSet_BMI2) || (isa == InstructionSet_LZCNT) || (isa == InstructionSet_POPCNT);
}
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