This is an archive of the discontinued LLVM Phabricator instance.

[VectorCombine] Limit scalarization known non-poison indices.
ClosedPublic

Authored by fhahn on Aug 3 2021, 9:00 AM.

Details

Summary

We can only trust the range of the index if it is guaranteed
non-poison.

Fixes PR50949.

Diff Detail

Event Timeline

fhahn created this revision.Aug 3 2021, 9:00 AM
fhahn requested review of this revision.Aug 3 2021, 9:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2021, 9:00 AM
lebedev.ri accepted this revision.Aug 3 2021, 9:25 AM
lebedev.ri added a subscriber: lebedev.ri.

I think this could use some comments (both before the check and in testcases) that freeze doesn't help.

This revision is now accepted and ready to land.Aug 3 2021, 9:25 AM
fhahn added a comment.Aug 3 2021, 1:08 PM

I think this could use some comments (both before the check and in testcases) that freeze doesn't help.

freeze would help, if we push it to the and and urem operands respectively I think. But I don't think there's an easy way to do this when using computeConstantRange. Not sure if there's potential for a convenient API that transforms a constant range which may include poison to one without? Otherwise I could match the and and urem patterns manually, which would allow inserting the freeze at the right place.

Not sure if there's potential for a convenient API that transforms a constant range which may include poison to one without?

Not sure how useful that would be in general, but maybe. I mean, "match the and and urem patterns manually" is basically such an API.

llvm/test/Transforms/VectorCombine/load-insert-store.ll
419

Please make sure we have a corresponding testcase with the appropriate freeze.

fhahn updated this revision to Diff 364440.Aug 5 2021, 6:26 AM

rebased after adding additional tests in 8d2a8ced00dc45605cb85.

fhahn added inline comments.Aug 5 2021, 7:43 AM
llvm/test/Transforms/VectorCombine/load-insert-store.ll
419

I added variants that either freeze the %idx operand or %idx.clamped in 8d2a8ced00dc