> On 24 Jul 2026, at 20:15, Jeffrey Law <[email protected]> wrote:
> 
> 
> 
> On 7/22/2026 9:24 AM, [email protected] wrote:
>> From: Kyrylo Tkachov <[email protected]>
>> 
>> init_noce_multiple_sets_info records earlier SET destinations that are
>> mentioned by a later SET source.  When a pseudo is set more than once, only
>> its most recent prior definition reaches that source.
>> 
>> Recording every definition is unsafe in the second
>> noce_convert_multiple_sets_1 attempt.  The newest definition can be emitted
>> directly into its target pseudo, making its replacement a no-op.  A later
>> replacement using an older definition then substitutes a stale value.
>> 
>> PR126184 contains the following dependency chain:
>> 
>>   c = x + 1;
>>   x = c * y;
>>   c = z + 3;
>>   y = c * x;
>> 
>> The unfixed conversion computes the last multiply with the temporary that
>> holds `x + 1`, rather than the reaching `z + 3` value.
>> 
>> The unfixed final sequence forms `x + 1` in x0 and later uses x0 as the
>> multiply operand:
>> 
>>   add     x0, x1, 1
>>   csel    x1, x1, x3, eq
>>   mul     x0, x1, x0
>> 
>> With the fix, x3 retains z until `z + 3` is formed and used by the multiply:
>> 
>>   add     x3, x3, 3
>>   csel    x0, x0, x1, ne
>>   mul     x3, x0, x3
>> 
>> Walk definitions from newest to oldest and record only the first match for
>> each pseudo.  Add an AArch64 execution test for the reported dependency.
>> 
>> Bootstrapped and tested on aarch64-none-linux-gnu and
>> x86_64-pc-linux-gnu.
>> 
>> gcc/ChangeLog:
>> 
>> PR rtl-optimization/126184
>> * ifcvt.cc (init_noce_multiple_sets_info): Record only the most
>> recent prior definition of each pseudo register.
>> 
>> gcc/testsuite/ChangeLog:
>> 
>> PR rtl-optimization/126184
>> * gcc.target/aarch64/pr126184.c: New test.
> OK

Thanks, I committed the two patches over the weekend.
Richard: is this and the prerequisite patch at:
https://gcc.gnu.org/cgit/gcc/commit/?id=7b4d5b42a78859b30c9b48fa0a426effbbd71ff7
Ok to backport for GCC 16.2?
They should be fairly localized wrong-code fixes for ifcvt.
Thanks,
Kyrill


> jeff

Reply via email to