Canonicalize PAVG builtins to IFN_AVG_CEIL for i386.
i386 PAVG builtins are now canonicalized to IFN_AVG_CEIL for better optimization.
The i386 PAVG builtins, which compute an unsigned average rounded up but use signed vector types, are now canonicalized to IFN_AVG_CEIL. This change involves view-converting operands to unsigned types and simplifies masked and unmasked calls. The optimization is applied when operands are equal for modes without IFN_AVG_CEIL optabs, enabling more generic simplifications.
In Details
The ix86_gimple_fold_builtin in config/i386/i386.cc now canonicalizes PAVG builtins to IFN_AVG_CEIL. This involves converting signed vector types to unsigned before computation to match the instruction's behavior (unsigned average rounded up). It aims to expose PAVG operations to more generic GIMPLE simplifications, particularly when masks are involved or operands are identical.
- PAVG builtins
- Built-in functions that compute an average of vector elements. On x86, they perform an unsigned average rounded up.
- IFN_AVG_CEIL
- An internal function (optab) representing an average with ceiling rounding, used for canonicalization and optimization.
- GIMPLE
- GCC's internal representation (IR) used between the front-end and the optimization passes. It's a three-address code form.
- optab
- A table of operations that GCC uses to represent built-in functions and operators, mapping them to internal functions or instruction patterns.