[llvm-dev] SelectionDAG.cpp: FindOptimalMemOpLowering behavior

Romaric Jodin via llvm-dev llvm-dev at lists.llvm.org
Thu May 16 05:26:19 PDT 2019

Hi all,

I'm have a question about the behavior of the "FindOptimalMemOpLowering"
It is mentioned that this function only need to look at the "DstAlign" and
not the "SrcAlign" because "SrcAlign" is always greater than "DstAlign".
But if "DstAlign" is equal to zero and "SrcAlign" to one the condition is
respected. But in this case, wouldn't we want to take "SrcAlign" into
account instead of "DstAlign".

I have a code where the source is a buffer of bytes (aligned on 1-byte for
my backend), and a destination which is the stack, which is seen by LLVM as
an object which alignment can change
(SelectionDAG.cpp: getMemcpyLoadsAndStores), and so "DstAlign" is set to

At the end, I have a memcpy which is inlined, the stores are well aligned
with the stack, but the loads are aligned on MVT:i64 because the "SrcAlign"
was not taken into account in "FindOptimalMemOpLowering".

I have the default implementation of the "getOptimalMemOpType".

Can someone tell me if I'm misunderstanding the behavior of this function,
or if there is something to fix.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190516/ce466fb4/attachment.html>

More information about the llvm-dev mailing list