Re: [PATCH bpf-next v2 03/13] bpf: track low-32 scalar equality across zero-extending movs
From: Alexei Starovoitov
Date: Sat Sep 12 2026 - 15:00:10 EST
On Thu Sep 10, 2026 at 9:46 AM PDT, Vineet Gupta wrote:
> Linked-scalar equality is full-64-bit only. A 32-bit mov from a source
> with unknown high bits therefore has to drop the relationship, and a later
> narrowing of the source never reaches the destination:
>
> r6 = ... /* full 64-bit unknown */
> w7 = w6 /* 32-bit zero-extending mov */
> if w6 != 0 goto ... /* not taken: r6's low 32 bits are 0 */
> if w7 == 0 goto ... /* not deduced today */
>
> Record a low-32-only link instead: dst shares src's low 32 bits and its
> high half is zero. On a later narrowing, sync_linked_regs() rebuilds such
> a register from the base rather than copying it, by re-applying the same
> zext_32_to_64() the mov used. The reverse direction is skipped: a ->subreg
> base knows nothing about a full register's high half.
at the first glance SUBREG_ZEXT is exactly the same as ADD_CONST32 delta == 0.
no?
Both are unidirectional:
w6->id == 1
w7->id == 1, add_const == 32, delta == 0
will zero extend w7.
This new SUBREG_ZEXT will do the same.
What am I missing?