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

Vectorizer avoids incorrect conversion of pow(x, 0.5) to sqrt(x)

Fixes vectorizer to not incorrectly transform pow(x, 0.5) into sqrt(x).

The GCC vectorizer previously misidentified pow(x, 0.5) as sqrt(x), leading to incorrect transformations. This patch corrects the pattern recognition in vect_recog_pow_pattern to only convert to sqrt when appropriate, specifically excluding cases involving signed zero or negative infinity. The fix also required adjustments to two test cases that relied on the old, incorrect behavior.

In Details

This patch addresses PR tree-optimization/126562 by refining the vectorizer's pattern matching for pow(x, 0.5). The previous vect_recog_pow_pattern in tree-vect-patterns.cc incorrectly recognized this as a square root operation. The correction ensures that the pattern only matches when the input x is non-negative, or specifically handles cases involving signed zero or negative infinity, preventing the incorrect transformation. Scalar aspects of this PR were addressed in a prior patch for PR tree-optimization/127544.

For Context
vectorizer
A compiler component that transforms code to use SIMD (Single Instruction, Multiple Data) instructions, allowing a single operation to be performed on multiple data elements simultaneously.
SIMD
Single Instruction, Multiple Data. A class of parallel computers in Flynn's taxonomy. It describes computers with individually specified memory for each processor. SIMD allows a single instruction to be executed on multiple data points at once.
pattern matching
In compilers, the process of identifying specific code structures or sequences that correspond to known operations or optimizations.
Filed Under: optimizationvectorizationbugfixaarch64