OSDN Git Service

[LegalizeIntegerTypes] When promoting the result of an extract_vector_elt also promot...
authorCraig Topper <craig.topper@intel.com>
Wed, 2 Jan 2019 17:58:30 +0000 (17:58 +0000)
committerCraig Topper <craig.topper@intel.com>
Wed, 2 Jan 2019 17:58:30 +0000 (17:58 +0000)
commit6ed7489c1e7b9aaaa19d3287e87d30be30ce9d83
tree56caa7f453c999a9b5935f03e8f52686c055c909
parent6529ef607e09be8dc2346fdf596d20770b400d1b
[LegalizeIntegerTypes] When promoting the result of an extract_vector_elt also promote the input type if necessary

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.

Differential Revision: https://reviews.llvm.org/D56176

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350236 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
test/CodeGen/X86/setcc-combine.ll