This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Check the right order for halves of VZIP/VUZP if both parts are used
ClosedPublic

Authored by mstorsjo on Aug 18 2017, 2:24 PM.

Details

Summary

This is the exact same fix as in SVN r247254. In that commit, the fix was applied only for isVTRNMask and isVTRN_v_undef_Mask, but the same issue is present for VZIP/VUZP as well.

This fixes PR33921.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Aug 18 2017, 2:24 PM
mstorsjo updated this revision to Diff 111795.Aug 18 2017, 9:28 PM
mstorsjo retitled this revision from [ARM] Avoid cases where isVZIPMask matches a mask where the first half is undef to [ARM] Check hidden assumptions for the form of isVZIPMask where both outputs are used.
mstorsjo edited the summary of this revision. (Show Details)

Understood the root cause better, with the hidden assumptions of isVZIPMask where both outputs are used.

mstorsjo updated this revision to Diff 111811.Aug 19 2017, 3:51 AM
mstorsjo retitled this revision from [ARM] Check hidden assumptions for the form of isVZIPMask where both outputs are used to [ARM] Check the right order for halves of VZIP/VUZP if both parts are used.
mstorsjo edited the summary of this revision. (Show Details)
mstorsjo added reviewers: jmolloy, LukeCheeseman.

After digging in further, I found an even more elegant way of fixing it. And when expanding that fix to isVUZPMask and isVTRNMask, I noticed that the exact same fix as I was trying to provide already was present in isVTRNMask. So expanding that fix to all of them now, with the same code formatting style as in the existing check.

rengolin accepted this revision.Aug 19 2017, 11:30 AM

Hi Martin,

This makes sense to me. Thanks for the great investigation and getting to the bottom of it with such a simple patch. LGTM.

cheers,
--renato

This revision is now accepted and ready to land.Aug 19 2017, 11:30 AM

Do you think it may be worthwhile to extract the operation into a function?

static unsigned SelectPairHalf(unsigned Elements, ArrayRef<int> Mask, unsigned Index) {
  if (Mask.size() == Elements * 2)
    return Index / Elements;
  return Mask[Index] == 0 ? 0 : 1;
}

Do you think it may be worthwhile to extract the operation into a function?

static unsigned SelectPairHalf(unsigned Elements, ArrayRef<int> Mask, unsigned Index) {
  if (Mask.size() == Elements * 2)
    return Index / Elements;
  return Mask[Index] == 0 ? 0 : 1;
}

Hmm, maybe. I want this backported to 5.0 though, so I'd rather not to make too much factorization in the fix itself. Perhaps a separate factorization commit on top afterwards, that doesn't have to be backported?

This revision was automatically updated to reflect the committed changes.