Bug 107061 - ENCODEKEY128 clobbers xmm4-xmm6
Summary: ENCODEKEY128 clobbers xmm4-xmm6
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 12.2.1
: P3 normal
Target Milestone: 11.4
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2022-09-27 19:29 UTC by H.J. Lu
Modified: 2022-09-29 18:58 UTC (History)
3 users (show)

See Also:
Host:
Target: i386
Build:
Known to work: 13.0
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2022-09-27 19:29:16 UTC
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.
Comment 1 GCC Commits 2022-09-28 18:16:26 UTC
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.
Comment 2 GCC Commits 2022-09-29 18:32:11 UTC
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)
Comment 3 GCC Commits 2022-09-29 18:57:58 UTC
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)
Comment 4 H.J. Lu 2022-09-29 18:58:38 UTC
Fixed for GCC 11.4, 12.3 and 13.