[all-commits] [llvm/llvm-project] a983ef: [DAGCombiner][AArch64][VE] Teach BuildUDIV/SDIV to...

Craig Topper via All-commits all-commits at lists.llvm.org
Fri May 12 09:06:33 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a983ef2c1743d8c8240b83ab307d7adcbaa73693
      https://github.com/llvm/llvm-project/commit/a983ef2c1743d8c8240b83ab307d7adcbaa73693
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2023-05-12 (Fri, 12 May 2023)

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

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

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.

I don't know if VE wants this div by constant optimization or not. If they
don't want it, they can use the isIntDivCheap hook to disable it.

Reviewed By: RKSimon

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




More information about the All-commits mailing list