[PATCH] D103421: [Constants] Extend support for scalable-vector splats

Fraser Cormack via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 31 10:53:08 PDT 2021


frasercrmck created this revision.
frasercrmck added reviewers: RKSimon, aqjune, craig.topper, sdesmalen, nikic, fhahn.
Herald added subscribers: dexonsmith, hiraditya.
frasercrmck requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.

A handful of miscellaneous changes are included:

- The function `isNotMinSignedValue` crashed when passed a

scalable-vector type, as it unconditionally cast to `FixedVectorType`

- Support for splats was added to `dyn_castNegVal` to better find test

instruction combiner test cases.

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, though
existing coverage is slim; it doesn't appear that there are any in-tree
uses of `Constant::isNegativeZeroValue`, for example.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103421

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103421.348841.patch
Type: text/x-patch
Size: 19675 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210531/e2327e8b/attachment.bin>


More information about the llvm-commits mailing list