2525package com .oracle .svm .core .graal .amd64 ;
2626
2727import static com .oracle .svm .core .util .VMError .unsupportedFeature ;
28+ import static jdk .vm .ci .amd64 .AMD64 .k0 ;
2829import static jdk .vm .ci .amd64 .AMD64 .k1 ;
2930import static jdk .vm .ci .amd64 .AMD64 .k2 ;
3031import static jdk .vm .ci .amd64 .AMD64 .k3 ;
@@ -129,14 +130,14 @@ public SubstrateAMD64RegisterConfig(ConfigKind config, MetaAccessProvider metaAc
129130 boolean haveAVX512 = ((AMD64 ) target .arch ).getFeatures ().contains (AMD64 .CPUFeature .AVX512F );
130131 ArrayList <Register > regs ;
131132 if (haveAVX512 ) {
132- /*
133- * GR-40969: We would like to use valueRegistersAVX512. However, we emit a mix of VEX
134- * and EVEX encoded instructions, and the VEX variants cannot address the extended
135- * AVX-512 registers (XMM16-31). For now, limit ourselves to XMM0-15.
136- */
137133 regs = new ArrayList <>();
138134 regs .addAll (valueRegistersAVX512 );
139- regs .addAll (MASK_REGISTERS );
135+ /*
136+ * valueRegistersAVX512 contains all mask registers, including k0. k0 is not a general
137+ * allocatable register, most instructions that read it interpret it as "no opmask"
138+ * rather than as a real opmask register.
139+ */
140+ regs .remove (k0 );
140141 } else {
141142 regs = new ArrayList <>();
142143 regs .addAll (valueRegistersSSE );
@@ -146,6 +147,7 @@ public SubstrateAMD64RegisterConfig(ConfigKind config, MetaAccessProvider metaAc
146147 regs .addAll (MASK_REGISTERS );
147148 }
148149 }
150+ VMError .guarantee (!regs .contains (k0 ), "We must never treat k0 as a general allocatable register." );
149151
150152 if (Platform .includedIn (InternalPlatform .WINDOWS_BASE .class )) {
151153 // This is the Windows 64-bit ABI for parameters.
0 commit comments