[PATCH] D77798: [Target][ARM] Fix VPT Block Pass miscompilation

Pierre van Houtryve via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 9 07:01:43 PDT 2020


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

This fixes a miscompilation I introduced in D75993 <https://reviews.llvm.org/D75993>: In that patch, I was switching back to a "T" predicate if an instruction in the "E" part of a VPT block was writing to VPR.
e.g.

  vpttet.s32	le, q3, r2
  vcmpt.s32	ge, q3, r3
  vstrwt.32	q0, [r4]
  vcmpe.i32	eq, q3, q1       ; There was a vpnot before the vcmp, so its predicate became 'e' and the vpnot was removed
  vstrwt.32	q2, [r4], #16   ; vcmp wrote to VPR, so the predicate became 'T' again -> this is incorrect

The correct code for above is this, instead:

  vpttee.s32	le, q3, r2
  vcmpt.s32	ge, q3, r3
  vstrwt.32	q0, [r4]
  vcmpe.i32	eq, q3, q1
  vstrwe.32	q2, [r4], #16 ; even if vcmp wrote to vpr, we keep the 'E'

To fix this, I simply removed all of the logic related to "swapping predicates back to T" in the MVE VPT Block Insertion pass.

I also had to rewrite one test so it'd still have a `vpttet` block - the previous version of the test became a `vpttee` with this change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77798

Files:
  llvm/lib/Target/ARM/MVEVPTBlockPass.cpp
  llvm/test/CodeGen/Thumb2/mve-pred-not.ll
  llvm/test/CodeGen/Thumb2/mve-vpt-block-elses.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77798.256277.patch
Type: text/x-patch
Size: 9429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200409/9e22caee/attachment.bin>


More information about the llvm-commits mailing list