Carve out a place in instcombine to put transformations which work knowing that their
authorChris Lattner <sabre@nondot.org>
Sun, 22 May 2011 18:18:41 +0000 (18:18 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 22 May 2011 18:18:41 +0000 (18:18 +0000)
commit1add46ddfa38f23669cb02de342fdb59a8709245
tree19ac31b2cf5eb88624f01757353c5b055f2b5920
parent75f4296c7c96499f4d8cdf90d5159f7965f94fd8
Carve out a place in instcombine to put transformations which work knowing that their
result is non-zero.  Implement an example optimization (PR9814), which allows us to
transform:
  A / ((1 << B) >>u 2)
into:
  A >>u (B-2)

which we compile into:

_divu3:                                 ## @divu3
leal -2(%rsi), %ecx
shrl %cl, %edi
movl %edi, %eax
ret

instead of:

_divu3:                                 ## @divu3
movb %sil, %cl
movl $1, %esi
shll %cl, %esi
shrl $2, %esi
movl %edi, %eax
xorl %edx, %edx
divl %esi, %eax
ret

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