This is an archive of the discontinued LLVM Phabricator instance.

DAG: Fix extract_subvector combine for a single element
ClosedPublic

Authored by arsenm on May 22 2018, 12:10 PM.

Details

Summary

This would fail before because 1x vectors aren't legal,
so instead just use the scalar type.

Avoids regressions in a future AMDGPU commit to add
v4i16/v4f16 as legal types.

Test update is just the one test that this triggers
on in tree now. It wasn't checking anything before.
The result is completely changed since the selects
are eliminated. Not sure if it's considered better
or not.

Diff Detail

Event Timeline

arsenm created this revision.May 22 2018, 12:10 PM
arsenm updated this revision to Diff 148072.May 22 2018, 12:13 PM

Fix missing test update

Can you clarify what "fails" means in your description? It would have create a <1 x iX> or <1 x fX> BUILD_VECTOR but it could only do that before type legalization if that type isn't legal. Type legalization should then scalarize that since its an illegal type.

Can you clarify what "fails" means in your description? It would have create a <1 x iX> or <1 x fX> BUILD_VECTOR but it could only do that before type legalization if that type isn't legal. Type legalization should then scalarize that since its an illegal type.

I mean the optimization doesn't happen, because the the "isOperationLegal(ISD::BUILD_VECTOR, MVT::v1X)" check fails after legalization.

Is v1X a legal type, but not a legal build_vector? i.e. how do you pass the isTypeLegal check?

arsenm added a comment.Jun 8 2018, 7:33 AM

Is v1X a legal type, but not a legal build_vector? i.e. how do you pass the isTypeLegal check?

No, v1 is illegal (as it should be on every target, although I know ARM at least has some legal v1 types as a hack). That was also failing, but now it's checking the legality of the scalar type

This revision is now accepted and ready to land.Jun 8 2018, 1:53 PM

Can this break if the build vector operand type is larger than the build vector element type? As happens when the element type isn’t a legal scalar type.

arsenm added a comment.Jun 8 2018, 2:14 PM

Can this break if the build vector operand type is larger than the build vector element type? As happens when the element type isn’t a legal scalar type.

There probably needs to be a truncate, but I don't know how to construct a test that would need this

arsenm closed this revision.Jun 11 2018, 2:32 PM

r334440. I added the truncate, but it's untested.