This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SVE] Move convert.{from,to}.svbool optimization into InstCombine
ClosedPublic

Authored by bsmith on Apr 26 2021, 8:55 AM.

Details

Summary

As part of this the ptrue coalescing done in SVEIntrinsicOpts has been
modified to not introduce redundant converts, since the convert removal
will no longer run after that optimisation to clean up.

Diff Detail

Event Timeline

bsmith created this revision.Apr 26 2021, 8:55 AM
bsmith requested review of this revision.Apr 26 2021, 8:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2021, 8:55 AM

Thanks for doing this! I think instcombine will be OK with altering the phi's and the walk like this.
It's a little simpler in MVE, as we end up converting predicates to/from i16, and just merge adjacent convert.to/convert.from.

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
288

Worklist isn't used, I don't think.

289

auto *
(And maybe just Type *)

llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-reinterpret.ll
262

Is this used? It may work fine without, and I don't see #0 used anywhere.

peterwaller-arm requested changes to this revision.Apr 27 2021, 9:22 AM

Couple of things which look like they need tidying up.

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
289

Nit: Complaint from clang tidy.

317

I see that the erasure of things from the worklist has been dropped, but not the worklist. Is it handled in replaceInstUsesWith?

326

Nit: Comment sounds incomplete and reads the same as the code. Suggestion: "Handle reinterprets of phi nodes." or drop the comment.

357

Another thing which appears not to have any uses.

This revision now requires changes to proceed.Apr 27 2021, 9:22 AM
bsmith updated this revision to Diff 341133.Apr 28 2021, 3:52 AM
bsmith marked 7 inline comments as done.
  • Remove redundant code
  • Satisfy 'auto' lint complaint
  • Clarify comment about phis
  • Add missing attributes to functions in test
peterwaller-arm accepted this revision.Apr 28 2021, 3:55 AM
This revision is now accepted and ready to land.Apr 28 2021, 3:55 AM

Since this change I get this warning when building:

[91/249] Building CXX object lib/Targ...h64CodeGen.dir/SVEIntrinsicOpts.cpp.o
/work/open_source/lldb-cross-compile/llvm-project/llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp:96:16: warning: ‘static llvm::IntrinsicInst* {anonymous}::SVEIntrinsicOpts::isReinterpretToSVBool(llvm::Value*)’ defined but not used [-Wunused-function]
   96 | IntrinsicInst *SVEIntrinsicOpts::isReinterpretToSVBool(Value *V) {
      |                ^~~~~~~~~~~~~~~~

FYI in case you meant to remove/still make use of that function.