[PATCH] D51988: [PowerPC] Folding XForm to DForm loads requires alignment for some DForm loads.

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 14 08:14:27 PDT 2018


nemanjai added a comment.

Please add a test case that we used to transform to a D-Form and no longer do with your patch (preferably one for DS-Form and one for DQ-Form).



================
Comment at: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:3067
+  // Going from XForm to DForm loads means that the load must be word aligned.
+  // XForm loads do not have this restriction.
+  if (ImmMO->isGlobal() && ImmMO->getGlobal()->getAlignment() < 4)
----------------
This comment also needs to be updated. The instruction does not require the data to be aligned, it requires the displacement to be a multiple of 4.
I suppose the problem is that unaligned data may reside at non-multiple-of-4 offsets from the base reg and we don't know yet if that is the case. However, adding the check here just shifts the bug because we could be handling an unaligned vector access with a DQ-Form instruction. If the data happens to be 4-byte aligned and the displacement ends up being 12, this check won't catch it and we're in just as much trouble.
So I am with Steven here that we should be doing the check in `isImmElgibleForForwarding()` where we have access to how this is being used and know what `ImmMustBeMultipleOf`.


https://reviews.llvm.org/D51988





More information about the llvm-commits mailing list