diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-11-15 08:26:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-15 22:26:34 +0900 |
commit | 75cf672b12d9dccf7b5f8730493e04d22f4ddbb7 (patch) | |
tree | 09c69729538089ef9af464a4a7c761cc73a13484 /flang/lib/Frontend/CompilerInvocation.cpp | |
parent | 6d858e2ad3502f787d3a51fb3d69139686812703 (diff) | |
download | llvm-75cf672b12d9dccf7b5f8730493e04d22f4ddbb7.zip llvm-75cf672b12d9dccf7b5f8730493e04d22f4ddbb7.tar.gz llvm-75cf672b12d9dccf7b5f8730493e04d22f4ddbb7.tar.bz2 |
[SDAG] Simplify is-power-of-2 codegen (#72275)
When x is not known to be nonzero, ctpop(x) == 1 is expanded to
x != 0 && (x & (x - 1)) == 0
resulting in codegen like
leal -1(%rdi), %eax
testl %eax, %edi
sete %cl
testl %edi, %edi
setne %al
andb %cl, %al
But another expression that works is
(x ^ (x - 1)) > x - 1
which has nicer codegen:
leal -1(%rdi), %eax
xorl %eax, %edi
cmpl %eax, %edi
seta %al
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions