[PATCH] D58567: [LegalizeTypes][AArch64][X86] Make type legalization of vector (S/U)ADD/SUB/MULO follow getSetCCResultType for the overflow bits. Make UnrollVectorOverflowOp properly convert from scalar boolean contents to vector boolean contents

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 22 17:40:04 PST 2019


craig.topper created this revision.
craig.topper added reviewers: spatel, RKSimon, nikic.
Herald added subscribers: dmgreen, kristof.beyls, javed.absar.

When promoting the over flow vector for these ops we should use the target's desired setcc result type. This way a v8i32 result type will use a v8i32 overflow vector instead of a v8i16 overflow vector. A v8i16 overflow vector will cause LegalizeDAG/LegalizeVectorOps to have to use v8i32 and truncate to v8i16 in its expansion. By doing this in type legalization instead, we get the truncate into the DAG earlier and give DAG combine more of a chance to optimize it.

We also have to fix unrolling to use the scalar setcc result type for the scalarized operation, and convert it to the required vector element type after the scalar operation. We have to observe the vector boolean contents when doing this conversion. The previous code was just taking the scalar result and putting it in the vector. But for X86 and AArch64 that would have only put a the boolean value in bit 0 of the element and left all other bits in the element 0. We need to ensure all bits in the element are the same. I'm using a select with constants here because that's what setcc unrolling in LegalizeVectorOps used.


https://reviews.llvm.org/D58567

Files:
  lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  test/CodeGen/AArch64/vec_uaddo.ll
  test/CodeGen/AArch64/vec_umulo.ll
  test/CodeGen/X86/vec_saddo.ll
  test/CodeGen/X86/vec_smulo.ll
  test/CodeGen/X86/vec_ssubo.ll
  test/CodeGen/X86/vec_uaddo.ll
  test/CodeGen/X86/vec_umulo.ll
  test/CodeGen/X86/vec_usubo.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58567.188013.patch
Type: text/x-patch
Size: 47918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190223/9f3599b5/attachment-0001.bin>


More information about the llvm-commits mailing list