This is an archive of the discontinued LLVM Phabricator instance.

[LegalizeIntegerTypes] When promoting the result of an extract_vector_elt also promote the input type if necessary
ClosedPublic

Authored by craig.topper on Dec 31 2018, 11:47 AM.

Details

Summary

By also promoting the input type we get a better idea for what scalar type to use. This can provide better results if the result of the extract is sign extended. What was previously happening is that the extract result would be legalized, sometime later the input of the sign extend would be legalized using the result of the extract. Then later the extract input would be legalized forcing a truncate into the input of the sign extend using a replace all uses. This requires DAG combine to combine out the sext/truncate pair. But sometimes we visited the truncate first and messed things up before the sext could be combined.

By creating the extract with the correct scalar type when we create legalize the result type, the truncate will be added right away. Then when the sign_extend input is legalized it will create an any_extend of the truncate which can be optimized by getNode to maybe remove the truncate. And then a sign_extend_inreg. Now DAG combine doesn't have to worry about getting rid of the extend.

This fixes the regression on X86 in D56156.

Diff Detail

Event Timeline

craig.topper created this revision.Dec 31 2018, 11:47 AM
RKSimon accepted this revision.Jan 2 2019, 2:35 AM

LGTM thanks

This revision is now accepted and ready to land.Jan 2 2019, 2:35 AM
This revision was automatically updated to reflect the committed changes.