This is the x86 part of v2, reworked to canonicalize PAVG target builtins to IFN_AVG_CEIL as suggested.
Bootstrapped on x86_64-pc-linux-gnu. The new x86 tests and the existing PAVG tests pass. ________________________________ From: Richard Biener <[email protected]> Sent: 22 July 2026 14:17 To: Odysseas Georgoudis <[email protected]> Cc: [email protected] <[email protected]>; [email protected] <[email protected]> Subject: Re: [PATCH] middle-end, i386: Fold averages with equal operands [PR122715] On Wed, Jul 15, 2026 at 7:43 AM Odysseas Georgoudis <[email protected]> wrote: > > This patch fixes PR middle-end/122715 by folding IFN_AVG_FLOOR (x, x) and > IFN_AVG_CEIL (x, x) to x. > > x86 PAVG intrinsics are represented by target builtins instead of > IFN_AVG_CEIL. The patch therefore also folds calls with equal operands in > ix86_gimple_fold_builtin. For masked forms, the fold is applied only when > every lane is enabled by the mask. The match.pd / gimple testcase part is OK. Please split the x86 target part to a separate patch (we might want to instead fold the target builtin to the internal function call?) Thanks, Richard. > Bootstrapped on x86_64-pc-linux-gnu. The new tests and the existing PAVG > focused tests pass. The target-independent match.pd fold was also tested > using an AArch64 cross-compiler.
0002-PR122715-i386.patch
Description: 0002-PR122715-i386.patch
