Re: arm32 build warnings in workqueue.c

From: Linus Torvalds
Date: Fri Jun 23 2023 - 15:34:24 EST


On Fri, 23 Jun 2023 at 12:16, Nick Desaulniers <ndesaulniers@xxxxxxxxxx> wrote:
>
> >
> > - movabsq $137438953440, %rcx # imm = 0x1FFFFFFFE0
> > - andq %rax, %rcx
> > - movabsq $68719476704, %rdx # imm = 0xFFFFFFFE0
> > - cmpq %rdx, %rcx
> > + shrq $5, %rax
> > + cmpl $2147483647, %eax # imm = 0x7FFFFFFF
> >
> > in several places.
>
> Sorry, are those equivalent? Before looks to me like:
>
> if (0xFFFFFFFE0 - (0x1FFFFFFFE0 & rax))
>
> and after
>
> if (0x7FFFFFFF - (rax >> 5))

I cut off some of the other changes, with the old (confused) code also doing

- shrq $5, %rax

later.

And yes, as far as I can tell, the comparisons are 100% equivalent.
Look at what happens when you shift that big mask down by 5..

> > My guess is that clang keeps an enum as an enum as long as possible -
> > including past some (really) simple simplification phases of the
> > optimizer.
>
> I don't think so.
> https://godbolt.org/z/M8746c49z
> That's LLVM IR as soon as it leaves the front end.

Hmm. I have

clang version 15.0.7 (Fedora 15.0.7-2.fc37)

and you can probably check the code generation of the current kernel
with and without that patch.

It might depend on exact config file - I'll send you mine in a
separate email to not pollute the mailing list.

Linus