GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc Performance Win

x86_64: Improve SSE Code Generation for 128-bit Integer Comparisons

Enables scalar-to-vector transformation for 128-bit integer comparisons on x86_64 with SSE, resulting in more efficient code.

The i386 STV pass has been enhanced to handle SUBREG conversions for TImode values, which allows scalar-to-vector transformation of 128-bit integer comparisons when compiling for x86_64 with SSE. This optimization avoids transferring 128-bit vectors to the scalar unit for equality testing, resulting in significantly more efficient code. For example, comparing two __m128i vectors for equality now uses pxor and ptest instructions, avoiding several move and logical operations.

In Details

This commit modifies the i386's STV (scalar-to-vector) pass to handle SUBREG conversions in TImode, specifically for the *cmpti_doubleword pattern. By allowing TImode SUBREGs, the pass can now transform scalar comparisons into vector comparisons using SSE instructions like pxor and ptest. This enhancement avoids unnecessary data transfers between scalar and vector units, resulting in improved code generation for 128-bit integer comparisons. The changes are mostly in config/i386/i386.c.

For Context

This commit optimizes how GCC generates code for comparing 128-bit integers on x86 processors that support SSE instructions. SSE allows the processor to perform the same operation on multiple data points simultaneously using vector registers. The change enables GCC to perform 128-bit integer comparisons using vector instructions instead of scalar instructions, which involves fewer data movements and operations, leading to faster code execution.

Filed Under: x86_64sseoptimizationcode generationvectorization