If a conditional branch jumps to the same target, remove the condition
authorPhilip Reames <listmail@philipreames.com>
Tue, 10 Mar 2015 22:52:37 +0000 (22:52 +0000)
committerPhilip Reames <listmail@philipreames.com>
Tue, 10 Mar 2015 22:52:37 +0000 (22:52 +0000)
commitfb4ffccacb6050a478a18f303bca53cc1ba4f9d6
tree09f47eb07e6f59c4e529429f6b344ab88b714c32
parent107918efa254841227ea3920db052f53337f5e0c
If a conditional branch jumps to the same target, remove the condition

Given that large parts of inst combine is restricted to instructions which have one use, getting rid of a use on the condition can help the effectiveness of the optimizer. Also, it allows the condition to potentially be deleted by instcombine rather than waiting for another pass.

I noticed this completely by accident in another test case. It's not anything that actually came from a real workload.

p.s. We should probably do the same thing for switch instructions.

Differential Revision: http://reviews.llvm.org/D8220

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231881 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstructionCombining.cpp
test/Transforms/InstCombine/branch.ll [new file with mode: 0644]