[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)
commite7981cee2427baba5ae2ec560a21c55658abf304
treebc475f4b13298424fafa24e5983c82f73552f5d2
parentaf7d7709d697ac7d0dbb726dd57466264ef89dad
[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

llvm-svn: 242437
llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
llvm/test/Transforms/StraightLineStrengthReduce/NVPTX/speculative-slsr.ll [new file with mode: 0644]