[all-commits] [llvm/llvm-project] a54102: [llvm] Add support for zero-width integers in Math...
Théo Degioanni via All-commits
all-commits at lists.llvm.org
Mon Apr 22 11:54:44 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a54102a093190f3a29add5d9327e62f13fce896a
https://github.com/llvm/llvm-project/commit/a54102a093190f3a29add5d9327e62f13fce896a
Author: Théo Degioanni <theo.degioanni.llvm.deluge062 at simplelogin.fr>
Date: 2024-04-22 (Mon, 22 Apr 2024)
Changed paths:
M llvm/include/llvm/Support/MathExtras.h
M llvm/unittests/ADT/APIntTest.cpp
M llvm/unittests/Support/MathExtrasTest.cpp
Log Message:
-----------
[llvm] Add support for zero-width integers in MathExtras.h (#87193)
MLIR uses zero-width integers, but also re-uses integer logic from LLVM
to avoid duplication. This creates issues when LLVM logic is used in
MLIR on integers which can be zero-width. In order to avoid
special-casing the bitwidth-related logic in MLIR, this PR adds support
for zero-width integers in LLVM's MathExtras (and consequently APInt).
While most of the logic in theory works the same way out of the box,
because bitshifting right by the entire bitwidth in C++ is undefined
behavior instead of being zero, some special cases had to be added.
Fortunately, it seems like the performance penalty is small. In x86,
this usually yields the addition of a predicated conditional move. I
checked that no branch is inserted in Arm too.
This happens to fix a crash in `arith.extsi` canonicalization in MLIR. I
think a follow-up PR to add tests for i0 in arith would be beneficial.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list