This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Add MachineMemOperand flags to the NodeID for MemSDNodes
ClosedPublic

Authored by sfertile on Oct 13 2017, 11:13 AM.

Details

Summary

During lowering we try to combine 2 loads with the same opcodes and operands but different flags on the MMO which triggers the assertion 'llvm::MachineMemOperand::refineAlignment(const llvm::MachineMemOperand*): Assertion MMO->getFlags() == getFlags() && "Flags mismatch!"' failed.

The initial selection dag ends up with 2 LD16s of 'FrameIndex 1 + 80' but one MMO has the dereferenceable flag and one does not.

t20: ch = lifetime.start t17, TargetFrameIndex:i64<0>
t46: i64 = add FrameIndex:i64<1>, Constant:i64<80>
t47: v4i32,ch = load<LD16[%0+80](align=8)(dereferenceable)> t20, t46, undef:i64
t50: ch = TokenFactor t24:1, t25, t28:1, t30, t32:1, t34, t37:1, t39, t42:1, t44, t47:1, t49
t69: v4i32,ch = load<LD16[FixedStack1+80](align=8)> t50, t46, undef:i64

While trying to lower t47 to a target specific LXVD2X we end up looking up the already lowered node for t69 which now has the same operands and we assert when trying to refine the alignment between the 2 MMOs.

I've added the subclass data to the FoldingSetNode for MemIntrinsicSDNodes which will make the relevant flags part of its signature.

Diff Detail

Repository
rL LLVM

Event Timeline

sfertile created this revision.Oct 13 2017, 11:13 AM
hfinkel edited edge metadata.Oct 25 2017, 5:31 PM

These flags should essentially already be added by the calls to ID.AddInteger(getSyntheticNodeSubclassData(... and ID.AddInteger(ST->getRawSubclassData()) and friends. Is this not happening uniformly?

sfertile updated this revision to Diff 120530.Oct 26 2017, 6:48 PM
sfertile edited the summary of this revision. (Show Details)

Changed direction due to my new understanding. I've added the subclass data to the FoldingSetNode for MemIntrinsicSDNodes.

hfinkel accepted this revision.Oct 26 2017, 7:59 PM

LGTM

Also, do we have a problem with prefetches in this regard too. For ISD::PREFETCH I see just this:

case ISD::PREFETCH: {
  const MemSDNode *PF = cast<MemSDNode>(N);
  ID.AddInteger(PF->getPointerInfo().getAddrSpace());
  break;
}

If you agree that there's also a problem here, please update this as well.

This revision is now accepted and ready to land.Oct 26 2017, 7:59 PM
This revision was automatically updated to reflect the committed changes.

LGTM

Also, do we have a problem with prefetches in this regard too. For ISD::PREFETCH I see just this:

case ISD::PREFETCH: {
  const MemSDNode *PF = cast<MemSDNode>(N);
  ID.AddInteger(PF->getPointerInfo().getAddrSpace());
  break;
}

If you agree that there's also a problem here, please update this as well.

I agree, I'll update and see if I can produce a test case for it.