[CGP] Add generic TargetLowering::shouldAlignPointerArgs() implementation
authorAlex Richardson <alexrichardson@google.com>
Thu, 9 Feb 2023 09:33:32 +0000 (09:33 +0000)
committerAlex Richardson <alexrichardson@google.com>
Thu, 9 Feb 2023 10:11:40 +0000 (10:11 +0000)
commitbd87a2449da0c82e63cebdf9c131c54a5472e3a7
treefe678b1b061975df0b2905d25d9c733d73bb5598
parentf28c28e6645723c01c73478a9d18f0bf0551767a
[CGP] Add generic TargetLowering::shouldAlignPointerArgs() implementation

This function was added for ARM targets, but aligning global/stack pointer
arguments passed to memcpy/memmove/memset can improve code size and
performance for all targets that don't have fast unaligned accesses.
This adds a generic implementation that adjusts the alignment to pointer
size if unaligned accesses are slow.
Review D134168 suggests that this significantly improves performance on
synthetic benchmarks such as Dhrystone on RV32 as it avoids memcpy() calls.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D134282
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/ARM/ARMISelLowering.h
llvm/test/CodeGen/RISCV/memcpy-inline.ll
llvm/test/CodeGen/WebAssembly/bulk-memory.ll
llvm/test/CodeGen/WebAssembly/bulk-memory64.ll
llvm/test/CodeGen/X86/GlobalISel/x86_64-irtranslator-struct-return.ll
llvm/test/Transforms/CodeGenPrepare/RISCV/adjust-memintrin-alignment.ll [new file with mode: 0644]