[PATCH] D17339: [SystemZ] Implement conditional returns.

Marcin Koƛcielnicki via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 17 09:28:29 PST 2016


koriakin created this revision.
koriakin added a reviewer: uweigand.
koriakin added a subscriber: llvm-commits.
Herald added a subscriber: aemerson.

Return is now considered a predicable instruction, and is converted
to a newly-added CondReturn (which maps to BCR to %r14) instruction by
the if conversion pass.

This transform triggers on a *lot* of tests, hence the huge diffstat.
The changes are mostly jX to br %r14 -> bXr %r14.  There are, however,
a few less fortunate changes:

- The if conversion happens before fused compares and BRCT are generated,
  thus winning over them.  Could be OK for the fused compares, I suppose,
  but BRCT should be better than cond return.  I suppose BRCT generation
  could be changed to cover that case, thoiugh.  I've added junk
  instructions before return in the CIJ* and BRCT testcases to make sure
  they are still emitted.
- When a function ends in a sufficiently simple loop with if, we go from
  that:

  loop:
  <instructions1>
  jX next
  <instructions2>
  next:
  <instructions3>
  jY loop
  br %r14

  to that:

  j loop
  next:
  <instructions3>
  bNYr %r14
  loop:
  <instructions1>
  jX next
  <instructions2>
  j next

  The net result is 1 more jump instruction in total (bad for code size),
  and 1 more instruction in the jX-not-taken path (bad for speed, if jX
  tends not to be taken and the loop is hot).

  Examples of this problem can be found in atomicrmw-minmax-*.ll and
  loop-01.ll .  I looked at how ARM deals with that, and it seems to
  have a similiar problem.


http://reviews.llvm.org/D17339

Files:
  lib/Target/SystemZ/SystemZAsmPrinter.cpp
  lib/Target/SystemZ/SystemZInstrInfo.cpp
  lib/Target/SystemZ/SystemZInstrInfo.h
  lib/Target/SystemZ/SystemZInstrInfo.td
  lib/Target/SystemZ/SystemZTargetMachine.cpp
  test/CodeGen/SystemZ/atomicrmw-minmax-03.ll
  test/CodeGen/SystemZ/atomicrmw-minmax-04.ll
  test/CodeGen/SystemZ/branch-05.ll
  test/CodeGen/SystemZ/cond-store-01.ll
  test/CodeGen/SystemZ/cond-store-02.ll
  test/CodeGen/SystemZ/cond-store-03.ll
  test/CodeGen/SystemZ/cond-store-04.ll
  test/CodeGen/SystemZ/cond-store-05.ll
  test/CodeGen/SystemZ/cond-store-06.ll
  test/CodeGen/SystemZ/fp-cmp-01.ll
  test/CodeGen/SystemZ/fp-cmp-02.ll
  test/CodeGen/SystemZ/fp-cmp-03.ll
  test/CodeGen/SystemZ/fp-cmp-04.ll
  test/CodeGen/SystemZ/fp-cmp-05.ll
  test/CodeGen/SystemZ/fp-move-09.ll
  test/CodeGen/SystemZ/fp-move-10.ll
  test/CodeGen/SystemZ/fp-sqrt-01.ll
  test/CodeGen/SystemZ/fp-sqrt-02.ll
  test/CodeGen/SystemZ/htm-intrinsics.ll
  test/CodeGen/SystemZ/int-cmp-01.ll
  test/CodeGen/SystemZ/int-cmp-02.ll
  test/CodeGen/SystemZ/int-cmp-03.ll
  test/CodeGen/SystemZ/int-cmp-04.ll
  test/CodeGen/SystemZ/int-cmp-05.ll
  test/CodeGen/SystemZ/int-cmp-06.ll
  test/CodeGen/SystemZ/int-cmp-07.ll
  test/CodeGen/SystemZ/int-cmp-08.ll
  test/CodeGen/SystemZ/int-cmp-09.ll
  test/CodeGen/SystemZ/int-cmp-10.ll
  test/CodeGen/SystemZ/int-cmp-11.ll
  test/CodeGen/SystemZ/int-cmp-12.ll
  test/CodeGen/SystemZ/int-cmp-13.ll
  test/CodeGen/SystemZ/int-cmp-14.ll
  test/CodeGen/SystemZ/int-cmp-15.ll
  test/CodeGen/SystemZ/int-cmp-16.ll
  test/CodeGen/SystemZ/int-cmp-17.ll
  test/CodeGen/SystemZ/int-cmp-18.ll
  test/CodeGen/SystemZ/int-cmp-19.ll
  test/CodeGen/SystemZ/int-cmp-20.ll
  test/CodeGen/SystemZ/int-cmp-21.ll
  test/CodeGen/SystemZ/int-cmp-22.ll
  test/CodeGen/SystemZ/int-cmp-23.ll
  test/CodeGen/SystemZ/int-cmp-24.ll
  test/CodeGen/SystemZ/int-cmp-25.ll
  test/CodeGen/SystemZ/int-cmp-26.ll
  test/CodeGen/SystemZ/int-cmp-27.ll
  test/CodeGen/SystemZ/int-cmp-28.ll
  test/CodeGen/SystemZ/int-cmp-29.ll
  test/CodeGen/SystemZ/int-cmp-30.ll
  test/CodeGen/SystemZ/int-cmp-31.ll
  test/CodeGen/SystemZ/int-cmp-32.ll
  test/CodeGen/SystemZ/int-cmp-33.ll
  test/CodeGen/SystemZ/int-cmp-34.ll
  test/CodeGen/SystemZ/int-cmp-35.ll
  test/CodeGen/SystemZ/int-cmp-36.ll
  test/CodeGen/SystemZ/int-cmp-37.ll
  test/CodeGen/SystemZ/int-cmp-38.ll
  test/CodeGen/SystemZ/int-cmp-39.ll
  test/CodeGen/SystemZ/int-cmp-40.ll
  test/CodeGen/SystemZ/int-cmp-41.ll
  test/CodeGen/SystemZ/int-cmp-42.ll
  test/CodeGen/SystemZ/int-cmp-43.ll
  test/CodeGen/SystemZ/int-cmp-44.ll
  test/CodeGen/SystemZ/int-cmp-46.ll
  test/CodeGen/SystemZ/int-cmp-47.ll
  test/CodeGen/SystemZ/int-cmp-48.ll
  test/CodeGen/SystemZ/loop-01.ll
  test/CodeGen/SystemZ/memchr-01.ll
  test/CodeGen/SystemZ/memchr-02.ll
  test/CodeGen/SystemZ/memcmp-01.ll
  test/CodeGen/SystemZ/memcmp-02.ll
  test/CodeGen/SystemZ/strcmp-01.ll
  test/CodeGen/SystemZ/strcmp-02.ll
  test/CodeGen/SystemZ/vec-intrinsics.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17339.48203.patch
Type: text/x-patch
Size: 182347 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160217/49f9ad12/attachment-0001.bin>


More information about the llvm-commits mailing list