[Fast-math] Disable "(C1/X)*C2 => (C1*C2)/X" if C1/X has multiple uses.
authorShuxin Yang <shuxin.llvm@gmail.com>
Thu, 19 Sep 2013 21:13:46 +0000 (21:13 +0000)
committerShuxin Yang <shuxin.llvm@gmail.com>
Thu, 19 Sep 2013 21:13:46 +0000 (21:13 +0000)
commitb1ccfb3a548e122e282cd62c534c4d47f5310bf6
tree39cebad965612ce61b118f5ad31abbd08026a31b
parentbf22298093d7069fbf3a3149d26fbcb4ad453ceb
[Fast-math] Disable "(C1/X)*C2 => (C1*C2)/X" if C1/X has multiple uses.

  If "C1/X" were having multiple uses, the only benefit of this
transformation is to potentially shorten critical path. But it is at the
cost of instroducing additional div.

  The additional div may or may not incur cost depending on how div is
implemented. If it is implemented using Newton–Raphson iteration, it dosen't
seem to incur any cost (FIXME). However, if the div blocks the entire
pipeline, that sounds to be pretty expensive. Let CodeGen to take care
this transformation.

  This patch sees 6% on a benchmark.

rdar://15032743

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191037 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
test/Transforms/InstCombine/fast-math.ll