[all-commits] [llvm/llvm-project] 4675db: [DAGCombiner] Add support for scalarising extracts...

David Sherwood via All-commits all-commits at lists.llvm.org
Wed Dec 4 02:27:14 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4675db5f394ebadd8a56bb17e2344da5c7779a68
      https://github.com/llvm/llvm-project/commit/4675db5f394ebadd8a56bb17e2344da5c7779a68
  Author: David Sherwood <david.sherwood at arm.com>
  Date:   2024-12-04 (Wed, 04 Dec 2024)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    M llvm/lib/Target/AArch64/AArch64ISelLowering.h
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    M llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    M llvm/test/CodeGen/AArch64/dag-combine-concat-vectors.ll
    A llvm/test/CodeGen/AArch64/extract-vector-cmp.ll
    M llvm/test/CodeGen/X86/vselect.ll

  Log Message:
  -----------
  [DAGCombiner] Add support for scalarising extracts of a vector setcc (#117566)

For IR like this:

%icmp = icmp ult <4 x i32> %a, splat (i32 5)
%res = extractelement <4 x i1> %icmp, i32 1

where there is only one use of %icmp we can take a similar approach
to what we already do for binary ops such add, sub, etc. and convert
this into

%ext = extractelement <4 x i32> %a, i32 1
%res = icmp ult i32 %ext, 5

For AArch64 targets at least the scalar boolean result will almost
certainly need to be in a GPR anyway, since it will probably be
used by branches for control flow. I've tried to reuse existing code
in scalarizeExtractedBinop to also work for setcc.

NOTE: The optimisations don't apply for tests such as
extract_icmp_v4i32_splat_rhs in the file

CodeGen/AArch64/extract-vector-cmp.ll

because scalarizeExtractedBinOp only works if one of the input
operands is a constant.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list