[llvm-dev] [buildSchedGraph] memory dependencies
Jonas Paulsson via llvm-dev
llvm-dev at lists.llvm.org
Thu Feb 4 05:46:05 PST 2016
On 2016-02-04 02:51, Hal Finkel wrote:
>
> diff --git a/lib/CodeGen/ScheduleDAGInstrs.cpp
> b/lib/CodeGen/ScheduleDAGInstrs.cpp
> index 00a0b0f..cd48f51 100644
> --- a/lib/CodeGen/ScheduleDAGInstrs.cpp
> +++ b/lib/CodeGen/ScheduleDAGInstrs.cpp
> @@ -584,6 +584,25 @@ static bool MIsNeedChainEdge(AliasAnalysis *AA,
> const MachineFrameInfo *MFI,
> if (!MIa->hasOneMemOperand() || !MIb->hasOneMemOperand())
> return true;
>
> + // If mem-operands show that the same address Value is used by
> both
> + // ("normal") instructions, simply check offsets and sizes of the
> + // accesses.
> + MachineMemOperand *MMOa = *MIa->memoperands_begin();
> + MachineMemOperand *MMOb = *MIb->memoperands_begin();
> + const Value *VALa = MMOa->getValue();
> + const Value *VALb = MMOb->getValue();
> + if (VALa == VALb &&
> + !MIa->hasUnmodeledSideEffects() &&
> !MIb->hasUnmodeledSideEffects() &&
> + !MIa->hasOrderedMemoryRef() && !MIb->hasOrderedMemoryRef()) {
> + int OffsetA = MMOa->getOffset(), OffsetB = MMOb->getOffset();
> + int WidthA = MMOa->getSize(), WidthB = MMOb->getSize();
> + int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
> + int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
> + int LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
> + if (LowOffset + LowWidth <= HighOffset)
> + return false;
> + }
> +
> if (isUnsafeMemoryObject(MIa, MFI, DL) ||
> isUnsafeMemoryObject(MIb,
> MFI, DL))
> return true;
>
> This looks reasonable to me.
OK - I will try this then for SystemZ as a starting point, and I also
need to do handle PseudoSourceValues, I guess.
It would be great to try this on a target that has done the register
analysis, and see if that is worth the effort... Any idea how to do that?
>
> + AAMDNodes AATagsA = MMOa->getAAInfo(), AATagsB =
> MMOb->getAAInfo();
> + if (AATagsA->TBAA && AATagsB->TBAA && AATagsA != AATagsB)
> + return false;
>
> I see that there is a TBAA method that is intended to give this type
> of
> result. So I wonder why this is not used?
>
> Would it be correct to implement SystemZs
> areMemAccessesTriviallyDisjoint() with the above code? (I am
> suspecting
> that perhaps my AAMDNodes check is incomplete)
> I don't understand this. The whole point of allowing backends use AA is to let the existing AA infrastructure take care of this. As I recall, SystemZ enabled AA in the backend, so why do you need anything special here?
>
> -Hal
I think I realized what was wrong: The AA was never called in the first
place, because the old isUnsafeMemoryObject() rejected the MI, because
the value could not be identified (argument). With the new patch applied
(D8705), AA was called and it works as you expected.
thanks,
Jonas
More information about the llvm-dev
mailing list