[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wgsK5H=ejAfFaABzK5PCb3=wqarq+L5frcTjRJkON9S+Q@mail.gmail.com>
Date: Fri, 23 Jun 2023 12:33:58 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Nick Desaulniers <ndesaulniers@...gle.com>
Cc: Dave Airlie <airlied@...il.com>,
Nathan Chancellor <nathan@...nel.org>,
Arnd Bergmann <arnd@...db.de>, Tejun Heo <tj@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
clang-built-linux <llvm@...ts.linux.dev>
Subject: Re: arm32 build warnings in workqueue.c
On Fri, 23 Jun 2023 at 12:16, Nick Desaulniers <ndesaulniers@...gle.com> 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
Powered by blists - more mailing lists