[all-commits] [llvm/llvm-project] d82758: [VectorCombine] Scalarize binop-like intrinsics (#...

Luke Lau via All-commits all-commits at lists.llvm.org
Wed May 21 01:24:35 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d827588c36131c342fe3602a2876b40efc39638a
      https://github.com/llvm/llvm-project/commit/d827588c36131c342fe3602a2876b40efc39638a
  Author: Luke Lau <luke at igalia.com>
  Date:   2025-05-21 (Wed, 21 May 2025)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/VectorCombine.cpp
    A llvm/test/Transforms/VectorCombine/X86/intrinsic-scalarize.ll
    A llvm/test/Transforms/VectorCombine/intrinsic-scalarize.ll

  Log Message:
  -----------
  [VectorCombine] Scalarize binop-like intrinsics (#138095)

Currently VectorCombine can scalarize vector compares and binary ops.
This extends it to also scalarize binary-op like intrinsics like umax,
minnum etc.

The motivation behind this is to scalarize more intrinsics in
VectorCombine rather than in DAGCombine, so we can sink splats across
basic blocks: see #137786

This currently has very little effect on generated code because
InstCombine doesn't yet canonicalize binary intrinsics where one operand
is a constant into the form that VectorCombine expects, i.e. `binop
(shuffle insert) const --> shuffle (binop insert const)`. The plan is to
land this first and then in a subsequent patch teach InstCombine to do
the canonicalization to avoid regressions in the meantime.

This uses `isTriviallyVectorizable` to determine whether or not an
intrinsic is safe to scalarize. There's also `isTriviallyScalarizable`,
but this seems more geared towards the Scalarizer pass and includes
intrinsics with multiple return values.

It also only handles intrinsics with two operands with the same type as
the return type. In the future we would generalize this to handle
arbitrary numbers of operands, including unary operators too, e.g. fneg
or fma, as well as different operand types, e.g. powi or scmp



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