[BypassSlowDivision] Teach bypass slow division not to interfere with div by constant...
authorCraig Topper <craig.topper@intel.com>
Tue, 21 Aug 2018 17:15:33 +0000 (17:15 +0000)
committerCraig Topper <craig.topper@intel.com>
Tue, 21 Aug 2018 17:15:33 +0000 (17:15 +0000)
commitb172b8884ac58dd8ca8f3ab63704c35fc7638458
treeaa876fd8d371a038da3b7f8c8252e1fbd2207bec
parent98eb4ae499892bc0d6dc273b37af417d8053098c
[BypassSlowDivision] Teach bypass slow division not to interfere with div by constant where constants have been constant hoisted, but not moved from their basic block

DAGCombiner doesn't pay attention to whether constants are opaque before doing the div by constant optimization. So BypassSlowDivision shouldn't introduce control flow that would make DAGCombiner unable to see an opaque constant. This can occur when a div and rem of the same constant are used in the same basic block. it will be hoisted, but not leave the block.

Longer term we probably need to look into the X86 immediate cost model used by constant hoisting and maybe not mark div/rem immediates for hoisting at all.

This fixes the case from PR38649.

Differential Revision: https://reviews.llvm.org/D51000

llvm-svn: 340303
llvm/lib/Transforms/Utils/BypassSlowDivision.cpp
llvm/test/CodeGen/X86/divide-by-constant.ll