[all-commits] [llvm/llvm-project] fd3b55: [Constants] Extend support for scalable-vector splats

Fraser Cormack via All-commits all-commits at lists.llvm.org
Mon Jun 7 06:46:25 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fd3b556958a9deee7ced33ec18b38c030145160b
      https://github.com/llvm/llvm-project/commit/fd3b556958a9deee7ced33ec18b38c030145160b
  Author: Fraser Cormack <fraser at codeplay.com>
  Date:   2021-06-07 (Mon, 07 Jun 2021)

  Changed paths:
    M llvm/lib/IR/Constants.cpp
    M llvm/test/Transforms/InstCombine/bitcast.ll
    M llvm/test/Transforms/InstCombine/div.ll
    M llvm/test/Transforms/InstCombine/fdiv.ll
    M llvm/test/Transforms/InstCombine/fmul.ll
    M llvm/test/Transforms/InstCombine/icmp-vec.ll
    M llvm/test/Transforms/InstCombine/sub.ll

  Log Message:
  -----------
  [Constants] Extend support for scalable-vector splats

This patch extends the various "isXXX" functions of the `Constant` class
to include scalable-vector splats.

In several "isXXX" functions, code that was separately inspecting
`ConstantVector` and `ConstantDataVector` was unified to use
`getSplatValue`, which already includes support for said splats.

In the varous "isNotXXX" functions, code was added to check whether the
scalar splat value -- if any -- satisfies the predicate.

An extra fix for `isNotMinSignedValue` was included, as it previously
crashed when passed a scalable-vector type because it unconditionally
cast to `FixedVectorType`

These changes address numerous missed optimizations, a compiler crash
mentioned above and -- perhaps most egregiously -- an infinite loop in
InstCombine due to the compiler breaking canonical form when it failed
to pick up on a splat in a select instruction.

Test cases have been added to cover as many of these functions as
possible, though existing coverage is slim; it doesn't appear that there
are any in-tree uses of `Constant::isNegativeZeroValue`, for example.

Reviewed By: RKSimon

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




More information about the All-commits mailing list