[PATCH] D137718: [AArch64][SVE] Fix bad PTEST(PTRUE_ALL, PTEST_LIKE) optimization

Cullen Rhodes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 08:03:54 PST 2022


c-rhodes created this revision.
c-rhodes added reviewers: paulwalker-arm, peterwaller-arm.
Herald added subscribers: psnobl, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: All.
c-rhodes requested review of this revision.
Herald added a project: LLVM.

AArch64InstrInfo::optimizePTestInstr attempts to remove a PTEST of a
predicate generating operation that identically sets flags (implictly).

When the mask is an all active of matching element size the PTEST is
currently removed. For while instructions this is correct since they
perform an implicit PTEST with an all active mask. However, for other
instructions such as compares the mask could be different.

This patch fixes this bug by only removing the PTEST if the same all
active mask is used by the predicating-generating instruction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137718

Files:
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/test/CodeGen/AArch64/sve-ptest-removal-cmpeq.ll
  llvm/test/CodeGen/AArch64/sve-ptest-removal-cmpeq.mir
  llvm/test/CodeGen/AArch64/sve-ptest-removal-cmpge.ll
  llvm/test/CodeGen/AArch64/sve-ptest-removal-cmpgt.ll
  llvm/test/CodeGen/AArch64/sve-ptest-removal-cmphi.ll
  llvm/test/CodeGen/AArch64/sve-ptest-removal-cmphs.ll
  llvm/test/CodeGen/AArch64/sve-ptest-removal-cmple.ll
  llvm/test/CodeGen/AArch64/sve-ptest-removal-cmplo.ll
  llvm/test/CodeGen/AArch64/sve-ptest-removal-cmpls.ll
  llvm/test/CodeGen/AArch64/sve-ptest-removal-cmplt.ll
  llvm/test/CodeGen/AArch64/sve-ptest-removal-cmpne.ll
  llvm/test/CodeGen/AArch64/sve-ptest-removal-match.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137718.474278.patch
Type: text/x-patch
Size: 13028 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221109/6246bc20/attachment.bin>


More information about the llvm-commits mailing list