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

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 31 11:48:14 PST 2018


craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel, efriedma.

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 <https://reviews.llvm.org/D56156>.


https://reviews.llvm.org/D56176

Files:
  lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  test/CodeGen/X86/setcc-combine.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56176.179772.patch
Type: text/x-patch
Size: 7344 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181231/865608da/attachment-0001.bin>


More information about the llvm-commits mailing list