[PATCH] D152059: [AVR] Replace shift-to-loop IR pass with common shift code
Patryk Wychowaniec via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 3 03:08:27 PDT 2023
Patryk27 created this revision.
Herald added subscribers: Jim, JDevlieghere, hiraditya, dylanmckay.
Herald added a project: All.
Patryk27 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
I'm submitting code on the behalf of aykevl which is the author of this patch -
the original commit message[1] says:
I wrote a late IR pass a while ago to replace non-constant shift
operations with a constant shift in a loop (see
https://reviews.llvm.org/D96677). This worked, but wasn't optimal and
there is a possibility later passes could again re-introduce such shift
operations. But as a stopgap, it worked well enough.
Now that constant 32-bit shift operations are optimized in a later
stage, we can use the same code to lower shift operations to loops.
This patch removes that IR pass and replaces it with one that runs
during ISel lowering, like the constant shift operations.
I did not expect this to affect binary size in any significant way, but
apparently it does. The compiler-rt library (when compiled inside
TinyGo) becomes 1.8% smaller, and picolibc becomes 0.4% smaller. That's
a nice win for what was intended to be mostly just a refactor.
Issue fixed here was discovered in rustc[2] and I can confirm that this patch
fixes the problem; using simavr I've checked the left- and right-shifts, and
the rest of integer math operations, and everything seems to work as intended.
Since aykevl mentioned that they are not currently working on the AVR
backend[1], please let me know if anything can / should be adjusted here and
I'll do my best :-)
[1] https://github.com/rust-lang/compiler-builtins/issues/523#issuecomment-1500734938
[2] https://github.com/rust-lang/compiler-builtins/issues/523,
https://github.com/rust-lang/rust/issues/112140
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152059
Files:
llvm/lib/Target/AVR/AVR.h
llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp
llvm/lib/Target/AVR/AVRISelLowering.cpp
llvm/lib/Target/AVR/AVRInstrInfo.cpp
llvm/lib/Target/AVR/AVRShiftExpand.cpp
llvm/lib/Target/AVR/AVRSubtarget.h
llvm/lib/Target/AVR/AVRTargetMachine.cpp
llvm/lib/Target/AVR/CMakeLists.txt
llvm/test/CodeGen/AVR/hardware-mul.ll
llvm/test/CodeGen/AVR/inline-asm/inline-asm3.ll
llvm/test/CodeGen/AVR/shift-expand.ll
llvm/test/CodeGen/AVR/shift-loop.ll
llvm/test/CodeGen/AVR/shift32.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152059.528086.patch
Type: text/x-patch
Size: 38949 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230603/8cbafc06/attachment.bin>
More information about the llvm-commits
mailing list