This is an archive of the discontinued LLVM Phabricator instance.

[IR] add shuffle queries for identity extend/extract
ClosedPublic

Authored by spatel on Aug 28 2018, 5:19 PM.

Details

Summary

This was one of the potential follow-ups suggested in D48236, and these will be used to make matching the patterns in PR38691 cleaner:
https://bugs.llvm.org/show_bug.cgi?id=38691

I'm not sure if we have preferred/existing vocabulary for these operations. In the DAG, I think these would be concat_vector with an undef operand or extract_subvector. Alternate naming suggestions welcome.

Diff Detail

Event Timeline

spatel created this revision.Aug 28 2018, 5:19 PM
lebedev.ri accepted this revision.Aug 29 2018, 11:42 AM

I think this looks good. Naming suggestion included.

include/llvm/IR/Instructions.h
2508–2514

isIdentityWithExtend() sounds very much like [[ https://llvm.org/docs/LangRef.html#zext-to-instruction | zext ]]-but-with-undef.
So maybe isIdentityWithExtract() can follow suit and be named isIdentityWithTruncate()?

This revision is now accepted and ready to land.Aug 29 2018, 11:42 AM
spatel added inline comments.Aug 29 2018, 12:10 PM
include/llvm/IR/Instructions.h
2508–2514

Hmm...that actually makes me less positive about 'extend' because we don't want to confuse these with the per-element zext/sext/trunc ops.

How about 'widen' and 'narrow'? That's actually how I've referred to these ops in a draft patch that would use them.

lebedev.ri added inline comments.Aug 29 2018, 12:35 PM
include/llvm/IR/Instructions.h
2508–2514

Yet another alternative name for isIdentityWithExtend(): isIdentityWithUndefPadding().

spatel marked an inline comment as done.Aug 30 2018, 6:56 AM
spatel added inline comments.
include/llvm/IR/Instructions.h
2508–2514

More exact description works for me. Let's go with that unless/until we think of something better.

lebedev.ri added inline comments.Aug 30 2018, 6:58 AM
include/llvm/IR/Instructions.h
2508–2514

In the same line of thought, isIdentityWithExtract() could be isIdentityPartial().
It won't be identity if the parital-ness is not at the end, so i'd think it is as descriptive.

spatel closed this revision.Aug 30 2018, 8:13 AM
spatel marked an inline comment as done.

I messed up linking the commit to the review - it was rL341075.

I went with isIdentityWithPadding() and kept isIdentityWithExtract() for now. I'll post a patch that uses these, and we can adjust the names if those don't feel right.