[PATCH] D79418: [LSR][ARM] Add new TTI hook to discard unwanted LSRUses

Pierre van Houtryve via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 5 07:31:06 PDT 2020


Pierre-vh created this revision.
Pierre-vh added reviewers: samparker, dmgreen, SjoerdMeijer.
Herald added subscribers: llvm-commits, danielkiss, hiraditya, kristof.beyls.
Herald added a project: LLVM.

Sometimes, LSR may change the way the ARM VCTP intrinsic's operand is calculated, and the change, while correct, will completely block tail-predication, for instance by defining the operand inside the loop.
This patch aims to fix this issue by adding a new TTI hook to tell LSR to ignore some instructions (for now, only the VCTP intrinsic on ARM).

This patch adds:

- A new TTI hook: `bool canLSRFixupInstruction(Instruction *I)`, which returns false when LSR shouldn't change `I`'s operands.
- A new function in LSR called `FilterOutUndesirableUses`, which calls this new TTI hook on every `LSRUse`'s `LSRFixup` UserInst, and deletes the `LSRUse` if the hook returns false for one of the instructions.
- An impl of this TTI hook for ARM, which returns false for VCTP intrinsics.

Note that I'm unsure about these changes. Do you feel like this is an appropriate fix for this issue?
Allowing LSR to do its thing and fixing it ourselves later in a backend pass is tricky and fragile, so I personally feel that fixing the problem in LSR directly is the best course of action.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79418

Files:
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
  llvm/lib/Target/ARM/ARMTargetTransformInfo.h
  llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
  llvm/test/Transforms/LoopStrengthReduce/ARM/forbidden-fixups.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79418.262102.patch
Type: text/x-patch
Size: 24463 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200505/fd7b03f8/attachment-0001.bin>


More information about the llvm-commits mailing list