[AVR] Expand large shifts early in IR
authorAyke van Laethem <aykevanlaethem@gmail.com>
Sun, 14 Feb 2021 22:29:59 +0000 (23:29 +0100)
committerAyke van Laethem <aykevanlaethem@gmail.com>
Sat, 24 Jul 2021 12:03:26 +0000 (14:03 +0200)
commit6aa9e746ebde6efd2479fa833d2d816d0a7bb353
tree50a8eb37a4b4456dd12616032787d9ebff3c7bfe
parent431a9414655ba4825a46e6765ef50a0b4ef7e101
[AVR] Expand large shifts early in IR

This patch makes sure shift instructions such as this one:

    %result = shl i32 %n, %amount

are expanded just before the IR to SelectionDAG conversion to a loop so
that calls to non-existing library functions such as __ashlsi3 are
avoided. The generated code is currently pretty bad but there's a lot of
room for improvement: the shift itself can be done in just four
instructions.

Differential Revision: https://reviews.llvm.org/D96677
llvm/lib/Target/AVR/AVR.h
llvm/lib/Target/AVR/AVRShiftExpand.cpp [new file with mode: 0644]
llvm/lib/Target/AVR/AVRTargetMachine.cpp
llvm/lib/Target/AVR/CMakeLists.txt
llvm/test/CodeGen/AVR/shift-expand.ll [new file with mode: 0644]