[PATCH] D67162: [InstCombine] Known-bits optimization for ARM MVE VADC.

Simon Tatham via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 05:50:11 PDT 2019


simon_tatham created this revision.
simon_tatham added reviewers: dmgreen, miyuki, ostannard.
Herald added subscribers: llvm-commits, hiraditya, kristof.beyls.
Herald added a project: LLVM.

The MVE VADC instruction reads and writes the carry bit at bit 29 of
the FPSCR register. The corresponding ACLE intrinsic is specified to
work with an integer in which the carry bit is stored at bit 0. So if
a user writes a code sequence in C that passes the carry from one VADC
to the next, like this,

  s0 = vadcq_u32(a0, b0, &carry);
  s1 = vadcq_u32(a1, b1, &carry);

then clang will generate IR for each of those operations that shifts
the carry bit up into bit 29 before the VADC, and after it, shifts it
back down and masks off all but the low bit. But in this situation
what you really wanted was two consecutive VADC instructions, so that
the second one directly reads the value left in FPSCR by the first,
without wasting several instructions on pointlessly clearing the other
flag bits in between.

This commit explains to InstCombine that the other bits of the flags
operand don't matter, and adds a test that demonstrates that all the
code between the two VADC instructions can be optimized away as a
result.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67162

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vadc-multiple.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67162.218667.patch
Type: text/x-patch
Size: 4596 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190904/73805388/attachment.bin>


More information about the llvm-commits mailing list