[NVPTX] enable SpeculativeExecution in NVPTX
authorJingyue Wu <jingyue@google.com>
Thu, 16 Jul 2015 20:13:48 +0000 (20:13 +0000)
committerJingyue Wu <jingyue@google.com>
Thu, 16 Jul 2015 20:13:48 +0000 (20:13 +0000)
commit1241b83d61b238cc8d9b01dc29c27a7c73194a76
treeaa826b6072f0d700e0ad3c59fc5f0b89166e6c32
parent66b12088cba33f19fcc7266f2dedf633cc723e92
[NVPTX] enable SpeculativeExecution in NVPTX

Summary:
SpeculativeExecution enables a series straight line optimizations (such
as SLSR and NaryReassociate) on conditional code. For example,

  if (...)
    ... b * s ...
  if (...)
    ... (b + 1) * s ...

speculative execution can hoist b * s and (b + 1) * s from then-blocks,
so that we have

  ... b * s ...
  if (...)
    ...
  ... (b + 1) * s ...
  if (...)
    ...

Then, SLSR can rewrite (b + 1) * s to (b * s + s) because after
speculative execution b * s dominates (b + 1) * s.

The performance impact of this change is significant. It speeds up the
benchmarks running EigenFloatContractionKernelInternal16x16
(https://bitbucket.org/eigen/eigen/src/ba68f42fa69e4f43417fe1e52669d4dd5d2b3bee/unsupported/Eigen/CXX11/src/Tensor/TensorContractionCuda.h?at=default#cl-526)
by roughly 2%. Some internal benchmarks that have the above code pattern
are improved by up to 40%. No significant slowdowns are observed on
Eigen CUDA microbenchmarks.

Reviewers: jholewinski, broune, eliben

Subscribers: llvm-commits, jholewinski

Differential Revision: http://reviews.llvm.org/D11201

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242437 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/NVPTX/NVPTXTargetMachine.cpp
test/Transforms/StraightLineStrengthReduce/NVPTX/speculative-slsr.ll [new file with mode: 0644]