This is the target-independent part of v2, split from the x86 changes as requested. The match.pd change and GIMPLE testcase are unchanged from v1.
IFN_AVG_FLOOR (x, x) and IFN_AVG_CEIL (x, x) both produce x, so fold these cases to x in match.pd. Bootstrapped on x86_64-pc-linux-gnu. The new GIMPLE test and the existing vector-average 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.
0001-PR122715-middle-end.patch
Description: 0001-PR122715-middle-end.patch
