[PATCH] D150333: [DAGCombiner][AArch64][VE] Teach BuildUDIV/SDIV to use 2x mul when mulh/mul_lohi are not available.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 10 17:22:29 PDT 2023


craig.topper created this revision.
craig.topper added reviewers: dmgreen, efriedma, RKSimon.
Herald added subscribers: steven.zhang, hiraditya, kristof.beyls.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a project: LLVM.

Correct the legality of i32 mul_lohi on AArch64.

Previously, AArch64 incorrectly reported i32 mul_lohi as Legal.
This allowed BuildUDIV/SDIV to use them. A later DAGCombiner would
replace them with MULHS/MULHU because only the high half was used.
This conversion does not check the legality of MULHS/MULHU under
the assumption that LegalizeDAG can turn it back into MUL_LOHI later.

After they are converted to MULHS/MULHU, DAGCombine ran and saw that
these operations aren't supported but an i64 MUL is. So they get
converted to that plus a shift. Without this, LegalizeDAG would
convert back MUL_LOHI and isel would fail to find a pattern.

This patch teaches BuildUDIV/SDIV to create the wide mul and shift
so that we can report the correct operation legality on AArch64. It
also enables div by constant folding for more cases on VE.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150333

Files:
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/VE/Scalar/div.ll
  llvm/test/CodeGen/VE/Scalar/rem.ll
  llvm/test/CodeGen/VE/Vector/vec_divrem.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150333.521174.patch
Type: text/x-patch
Size: 6945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230511/e25b0b00/attachment.bin>


More information about the llvm-commits mailing list