OSDN Git Service

Merging r340303:
authorHans Wennborg <hans@hanshq.net>
Tue, 21 Aug 2018 23:07:11 +0000 (23:07 +0000)
committerHans Wennborg <hans@hanshq.net>
Tue, 21 Aug 2018 23:07:11 +0000 (23:07 +0000)
commit9df0977d9409b093156ebbd8e1ac99bc32b9eb39
tree4ce338345f8532ef6582d2fa9c41e869e919a73d
parent57aa5d99a1d5a3a5836691cbc21cd228a5b3d379
Merging r340303:
------------------------------------------------------------------------
r340303 | ctopper | 2018-08-21 19:15:33 +0200 (Tue, 21 Aug 2018) | 9 lines

[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
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_70@340359 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/BypassSlowDivision.cpp
test/CodeGen/X86/divide-by-constant.ll