The current ENCODEKEY128 clears xmm4-xmm6. But Intel key lock spec has XMM4 through XMM6 are reserved for future usages and software should not rely upon them being zeroed. xmm4-xmm6 should be marked as clobbered, not zeroed for future compatibility.
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>: https://gcc.gnu.org/g:db288230db55dc1ff626f46c708b555847013a41 commit r13-2919-gdb288230db55dc1ff626f46c708b555847013a41 Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Sep 27 16:19:11 2022 -0700 i386: Mark XMM4-XMM6 as clobbered by encodekey128/encodekey256 encodekey128 and encodekey256 operations clear XMM4-XMM6. But it is documented that XMM4-XMM6 are reserved for future usages and software should not rely upon them being zeroed. Change encodekey128 and encodekey256 to clobber XMM4-XMM6. gcc/ PR target/107061 * config/i386/predicates.md (encodekey128_operation): Check XMM4-XMM6 as clobbered. (encodekey256_operation): Likewise. * config/i386/sse.md (encodekey128u32): Clobber XMM4-XMM6. (encodekey256u32): Likewise. gcc/testsuite/ PR target/107061 * gcc.target/i386/keylocker-encodekey128.c: Don't check XMM4-XMM6. * gcc.target/i386/keylocker-encodekey256.c: Likewise.
The releases/gcc-12 branch has been updated by H.J. Lu <hjl@gcc.gnu.org>: https://gcc.gnu.org/g:f1454a75c9a165c0ba30833f23f799044fd7a7fe commit r12-8795-gf1454a75c9a165c0ba30833f23f799044fd7a7fe Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Sep 27 16:19:11 2022 -0700 i386: Mark XMM4-XMM6 as clobbered by encodekey128/encodekey256 encodekey128 and encodekey256 operations clear XMM4-XMM6. But it is documented that XMM4-XMM6 are reserved for future usages and software should not rely upon them being zeroed. Change encodekey128 and encodekey256 to clobber XMM4-XMM6. gcc/ PR target/107061 * config/i386/predicates.md (encodekey128_operation): Check XMM4-XMM6 as clobbered. (encodekey256_operation): Likewise. * config/i386/sse.md (encodekey128u32): Clobber XMM4-XMM6. (encodekey256u32): Likewise. gcc/testsuite/ PR target/107061 * gcc.target/i386/keylocker-encodekey128.c: Don't check XMM4-XMM6. * gcc.target/i386/keylocker-encodekey256.c: Likewise. (cherry picked from commit db288230db55dc1ff626f46c708b555847013a41)
The releases/gcc-11 branch has been updated by H.J. Lu <hjl@gcc.gnu.org>: https://gcc.gnu.org/g:f8204b10e6bae0721ab74ad77a80b3761ebaf501 commit r11-10279-gf8204b10e6bae0721ab74ad77a80b3761ebaf501 Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Sep 27 16:19:11 2022 -0700 i386: Mark XMM4-XMM6 as clobbered by encodekey128/encodekey256 encodekey128 and encodekey256 operations clear XMM4-XMM6. But it is documented that XMM4-XMM6 are reserved for future usages and software should not rely upon them being zeroed. Change encodekey128 and encodekey256 to clobber XMM4-XMM6. gcc/ PR target/107061 * config/i386/predicates.md (encodekey128_operation): Check XMM4-XMM6 as clobbered. (encodekey256_operation): Likewise. * config/i386/sse.md (encodekey128u32): Clobber XMM4-XMM6. (encodekey256u32): Likewise. gcc/testsuite/ PR target/107061 * gcc.target/i386/keylocker-encodekey128.c: Don't check XMM4-XMM6. * gcc.target/i386/keylocker-encodekey256.c: Likewise. (cherry picked from commit db288230db55dc1ff626f46c708b555847013a41)
Fixed for GCC 11.4, 12.3 and 13.