RFR: 8277843: [Vector API] scalar2vector shouldn't be used for mask operations if Op_MaskAll is unavailable
Jatin Bhateja
jbhateja at openjdk.java.net
Fri Nov 26 06:54:07 UTC 2021
On Thu, 25 Nov 2021 14:41:27 GMT, Jie Fu <jiefu at openjdk.org> wrote:
> Hi all,
>
> This bug was first observed on x86_32/AVX512.
> It caused 62 vector api test failures.
>
> ==============================
> Test summary
> ==============================
> TEST TOTAL PASS FAIL ERROR
>>> jtreg:test/jdk/jdk/incubator/vector 74 12 62 0 <<
> ==============================
>
>
> You can easily reproduce this bug on an AVX512 machine with x86_32.
> Or you can also reproduce it on an AVX512 machine with x86_64 if you disable `Op_MaskAll` like this.
>
> diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad
> index 3f6d5a44b0d..d5a751b310d 100644
> --- a/src/hotspot/cpu/x86/x86.ad
> +++ b/src/hotspot/cpu/x86/x86.ad
> @@ -1819,6 +1819,7 @@ const bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType
> }
> break;
> case Op_MaskAll:
> + return false;
> if (!is_LP64 || !VM_Version::supports_evex()) {
> return false;
> }
>
>
> The failure reason is that `VectorNode::scalar2vector` generate incorrect IR for mask operations if `Op_MaskAll` is unavailable.
> So it shouldn't be used for mask operations if `Op_MaskAll` is unavailable.
>
> Testing (with two more bug fixes https://github.com/openjdk/jdk/pull/6535 and https://github.com/openjdk/jdk/pull/6533):
> - vector api tests on {x86_64, x86_32}/{AVX512, AVX256}, all passed
> - vector api tests on aarch64, all passed
>
> Thanks.
> Best regards,
> Jie
Hi @DamonFool ,
MaskAll is only supported for targets having predicate registers, in all other cases a Replicate node should be generated.
Ideal type of Replicate node should be TypeVect, reported problem seems to be occurring because ideal type of Replicate Node is TypeVectMask.
I think following fix should be sufficient
diff --git a/src/hotspot/share/opto/vectornode.cpp b/src/hotspot/share/opto/vectornode.cpp
index 6a5b0b9b014..f6c483cf62c 100644
--- a/src/hotspot/share/opto/vectornode.cpp
+++ b/src/hotspot/share/opto/vectornode.cpp
@@ -588,13 +588,13 @@ VectorNode* VectorNode::make(int opc, Node* n1, Node* n2, Node* n3, uint vlen, B
// Scalar promotion
VectorNode* VectorNode::scalar2vector(Node* s, uint vlen, const Type* opd_t, bool is_mask) {
BasicType bt = opd_t->array_element_basic_type();
- const TypeVect* vt = opd_t->singleton() ? TypeVect::make(opd_t, vlen, is_mask)
- : TypeVect::make(bt, vlen, is_mask);
-
if (is_mask && Matcher::match_rule_supported_vector(Op_MaskAll, vlen, bt)) {
+ const TypeVect* vt = TypeVect::make(opd_t, vlen, is_mask);
return new MaskAllNode(s, vt);
}
+ const TypeVect* vt = opd_t->singleton() ? TypeVect::make(opd_t, vlen)
+ : TypeVect::make(bt, vlen);
switch (bt) {
case T_BOOLEAN:
case T_BYTE:
Best Regards,
Jatin
-------------
PR: https://git.openjdk.java.net/jdk/pull/6562
More information about the hotspot-compiler-dev
mailing list