[LLVMdev] Alignment of constant loads
Paul Redmond
paul at rapidmind.com
Mon Sep 15 14:45:22 PDT 2008
Hi Dan,
> It looks like the best way to do this is to visit the handful of
> places in legalize that create loads from constant pools and
> add alignment parameters to the getLoad/getExtLoad calls.
>
> If you move the handling of Alignment==0 out of ScheduleDAGEmit.cpp
> and into SelectionDAG::getConstantPool, you can then have legalize
> read the alignment from the node, instead of making its own
> decision:
> cast<ConstantPoolSDNode>(CPIdx)->getAlignment()
>
>
I followed your suggestion but I've come across a bit of a snag. If you
get the alignment in LegalizeDAG using:
SDValue CPIdx = DAG.getConstantPool(LLVMC, TLI.getPointerTy());
unsigned Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlignment();
The ConstantPoolSDNode is created using MVT i32 (TLI.getPointerTy()) and
the alignment is 4 bytes. It seems there is not enough information to
know that the final MVT will be v4f32 so passing the alignment to
getLoad/getExtLoad in LegalizeDAG will still generate unaligned loads
for constant vectors.
Any ideas?
thanks,
Paul
More information about the llvm-dev
mailing list