GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
tree-optimization Performance Win

Vectorization precision logic corrected for non-truncatable operations.

GCC's vectorization pass now correctly handles precision for non-truncatable operations and shift amounts, preventing incorrect code generation.

This commit corrects two issues in GCC’s vectorization precision logic. First, for non-truncatable operations like TRUNC_DIV_EXPR, the minimum input precision is no longer propagated if the operation might remain scalar, thus avoiding incorrect narrowing of inputs. Second, for shift operations (LSHIFT_EXPR, RSHIFT_EXPR), the minimum input precision is not propagated to the shift amount itself, preventing the shift count from being incorrectly narrowed and leading to wrong shift results. New test cases verify these fixes for loop and basic block vectorization.

In Details

This patch refines vect_determine_precisions_from_range and vect_determine_min_output_precision_1 within the GCC tree-vectorizer. In vect_determine_precisions_from_range, it adds a check for vect_truncatable_operation_p before calling vect_set_min_input_precision. This prevents erroneous precision propagation for non-truncatable operations (like division/remainder) that might remain scalar during SLP vectorization, avoiding potential code generation errors due to input narrowing. In vect_determine_min_output_precision_1, it now returns false if the use operand is the shift amoun…

For Context
tree-optimization
A phase in the GCC compilation process that manipulates the intermediate representation (GIMPLE 'tree') to improve code efficiency.
vectorization
An optimization technique that allows the compiler to perform the same operation on multiple data elements simultaneously, typically using SIMD (Single Instruction, Multiple Data) instructions.
SLP vectorization
Superword-Level Parallelism vectorization. A compiler optimization that identifies sequences of identical scalar operations that can be vectorized, even if they are not part of a loop.
TRUNC_DIV_EXPR
A GCC internal representation for a division operation that truncates the result towards zero.
precision
In the context of data types, the number of bits used to represent a value, which determines its range and accuracy.
LSHIFT_EXPR / RSHIFT_EXPR
GCC internal representations for left and right shift operations, respectively.
Filed Under: optimizationvectorizationGCC