[PATCH] D40664: [SelectionDAG][X86][AArch64] Require targets to specify the promotion type when using setOperationAction Promote for INT_TO_FP and FP_TO_INT

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 11:51:23 PST 2017


craig.topper created this revision.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.

Currently the promotion for these ignores the normal getTypeToPromoteTo and instead just tries to double the element width. This is because the default behavior of getTypeToPromote to just adds 1 to the SimpleVT, which has the affect of increasing the element count while keeping the scalar size the same.

If multiple steps are required to get to a legal operation type, int_to_fp will be promoted multiple times. And fp_to_int will keep trying wider types in a loop until it finds one that works.

getTypeToPromoteTo does have the ability to query a promotion map to get the type and not do the increasing behavior. It seems better to just let the target specify the promotion type in the map explicitly instead of letting the legalizer iterate via widening.

FWIW, it's worth I think for any other vector operations that need to be promoted, we have to specify the type explicitly because the default behavior of getTypeToPromote isn't useful for vectors. The other types of promotion already require either the element count is constant or the total vector width is constant, but neither happens by incrementing the SimpleVT enum. In fact I think this code from AArch64 is wrong and untested.

  setOperationAction(ISD::FREM,    MVT::v4f16, Promote);
  setOperationAction(ISD::FREM,    MVT::v8f16, Promote);


https://reviews.llvm.org/D40664

Files:
  lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
  lib/Target/AArch64/AArch64ISelLowering.cpp
  lib/Target/X86/X86ISelLowering.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40664.124980.patch
Type: text/x-patch
Size: 8121 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171130/f723cd5a/attachment.bin>


More information about the llvm-commits mailing list