This is an archive of the discontinued LLVM Phabricator instance.

[X86] Do not assume types are legal in getFauxShuffleMask
ClosedPublic

Authored by bjope on Mar 31 2020, 4:44 AM.

Details

Summary

Make sure we do not assert on value types not being
simple in getFauxShuffleMask when analysing operations
such as "v8i16 = truncate v8i24".

Diff Detail

Event Timeline

bjope created this revision.Mar 31 2020, 4:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 31 2020, 4:44 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
RKSimon added inline comments.Mar 31 2020, 5:04 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
7554–7558

Nice catch! We actually need to be more thorough, matching what we do for the extensions (further down the function):

SDValue Src = N.getOperand(0);
EVT SrcVT = Src.getValueType();

// Truncated source must be a simple vector.
if (!SrcVT.isSimple() || (SrcVT.getSizeInBits() % 128) != 0 ||
    (SrcVT.getScalarSizeInBits() % 8) != 0)
  return false;
llvm/test/CodeGen/X86/shuffle-combine-crash-3.ll
61

This can probably be reduced/cleaned up more?

bjope marked 2 inline comments as done.Mar 31 2020, 6:11 AM
bjope added inline comments.
llvm/lib/Target/X86/X86ISelLowering.cpp
7554–7558

Ok, I'll copy that.

I was wondering if perhaps this whole thing should be avoided until we have legalized types? But maybe we want to do these combines earlier than that for some reason. But then I guess we still need the tests on bit sizes, so it wouldn't be enough.

llvm/test/CodeGen/X86/shuffle-combine-crash-3.ll
61

I did some attempts to reduce it (for example removing the first insertelement/shufflevector instructions using input arguments, but then I got a lot more asm instructions in the output).

But given the feedback that the code change is reasonable, then I feel that I can invest some more time on reducing the test case.

bjope updated this revision to Diff 253868.Mar 31 2020, 6:55 AM

Fixups after review. Managed to reduce the test case a bit.

bjope marked 2 inline comments as done.Mar 31 2020, 7:26 AM
RKSimon accepted this revision.Apr 1 2020, 12:26 AM

LGTM - cheers

This revision is now accepted and ready to land.Apr 1 2020, 12:26 AM
This revision was automatically updated to reflect the committed changes.