]> granicus.if.org Git - llvm/commit
Teach SimplifyDemandedUseBits that adding or subtractings 0s from every bit below...
authorCraig Topper <craig.topper@gmail.com>
Wed, 12 Apr 2017 16:49:59 +0000 (16:49 +0000)
committerCraig Topper <craig.topper@gmail.com>
Wed, 12 Apr 2017 16:49:59 +0000 (16:49 +0000)
commit3461e9c2e46c729e25b9260c6053c98f9c1d1c3f
tree7edde163bc3088586ef42c23aec838949818e63b
parentef86a1e6af965e1566265b1383976825f0342b84
Teach SimplifyDemandedUseBits that adding or subtractings 0s from every bit below the highest demanded bit can be simplified

If we are adding/subtractings 0s below the highest demanded bit we can just use the other operand and remove the operation.

My primary motivation is observing that we can call ShrinkDemandedConstant for the add/sub and create a 0 constant, rather than removing the add completely. In the case I saw, we modified the constant on an add instruction to a 0, but the add is not put into the worklist. So we didn't revisit it until the next InstCombine iteration. This caused an IR modification to remove add and a subsequent iteration to be ran.

With this change we get bypass the add in the first iteration and prevent the second iteration from changing anything.

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

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