[PATCH] D28813: [CodeGenPrepare] Sink and duplicate more 'and' instructions.

Geoff Berry via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 10:14:51 PST 2017


gberry created this revision.
Herald added a subscriber: aemerson.

Rework the code that was sinking/duplicating (icmp and, 0) sequences
into blocks where they were being used by conditional branches to form
more tbz instructions on AArch64.  The new code is more general in that
it just looks for 'and's that have all icmp 0's as users, with a target
hook used to select which subset of 'and' instructions to consider.
This change also enables 'and' sinking for X86, where it is more widely
beneficial than on AArch64.

The 'and' sinking/duplicating code is moved into the optimizeInst phase
of CodeGenPrepare, where it can take advantage of the fact the
OptimizeCmpExpression has already sunk/duplicated any icmps into the
blocks where they are used.  One minor complication from this change is
that optimizeLoadExt needed to be updated to always mark 'and's it has
determined should be in the same block as their feeding load in the
InsertedInsts set to avoid an infinite loop of hoisting and sinking the
same 'and'.

This change fixes a regression on X86 in the tsan runtime caused by
moving GVNHoist to a later place in the optimization pipeline (see
PR31382).


https://reviews.llvm.org/D28813

Files:
  include/llvm/Target/TargetLowering.h
  lib/CodeGen/CodeGenPrepare.cpp
  lib/CodeGen/TargetLoweringBase.cpp
  lib/Target/AArch64/AArch64ISelLowering.cpp
  lib/Target/AArch64/AArch64ISelLowering.h
  lib/Target/X86/X86ISelLowering.cpp
  lib/Target/X86/X86ISelLowering.h
  test/CodeGen/AArch64/and-sink.ll
  test/CodeGen/AArch64/fast-isel-tbz.ll
  test/CodeGen/X86/and-sink.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28813.84696.patch
Type: text/x-patch
Size: 19096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170117/bfc7b986/attachment.bin>


More information about the llvm-commits mailing list