[llvm/CodeGen] Add ExpandLargeDivRem pass
authorMatthias Gehre <matthias.gehre@xilinx.com>
Wed, 25 May 2022 11:19:28 +0000 (12:19 +0100)
committerMatthias Gehre <matthias.gehre@xilinx.com>
Fri, 26 Aug 2022 10:55:15 +0000 (11:55 +0100)
commit3e39b271016837425038e55e57c39e5e9b289975
tree563ef8f9c60d80ba2e186b8fce4d046f9c17f81c
parentbb26ebb4d18c1877cc6fd17aa803609abeb95096
[llvm/CodeGen] Add ExpandLargeDivRem pass

Adds a pass ExpandLargeDivRem to expand div/rem instructions
with more than 128 bits into a loop computing that value.

As discussed on https://reviews.llvm.org/D120327, this approach has the advantage
that it is independent of the runtime library. This also helps the clang driver,
which otherwise would need to understand enough about the runtime library
to know whether to allow _BitInts with more than 128 bits.

Targets are still free to disable this pass and instead provide a faster
implementation in a runtime library.

Fixes https://github.com/llvm/llvm-project/issues/44994

Differential Revision: https://reviews.llvm.org/D126644
15 files changed:
llvm/include/llvm/CodeGen/ExpandLargeDivRem.h [new file with mode: 0644]
llvm/include/llvm/CodeGen/MachinePassRegistry.def
llvm/include/llvm/CodeGen/Passes.h
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/LinkAllPasses.h
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/CodeGen/CodeGen.cpp
llvm/lib/CodeGen/ExpandLargeDivRem.cpp [new file with mode: 0644]
llvm/lib/Transforms/Utils/IntegerDivision.cpp
llvm/test/CodeGen/X86/urem-seteq.ll
llvm/test/Transforms/ExpandLargeDivRem/sdiv129.ll [new file with mode: 0644]
llvm/test/Transforms/ExpandLargeDivRem/srem129.ll [new file with mode: 0644]
llvm/test/Transforms/ExpandLargeDivRem/udiv129.ll [new file with mode: 0644]
llvm/test/Transforms/ExpandLargeDivRem/urem129.ll [new file with mode: 0644]
llvm/tools/opt/opt.cpp