[InstCombine] Fix regression introduced at r227197.
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Fri, 13 Feb 2015 16:33:34 +0000 (16:33 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Fri, 13 Feb 2015 16:33:34 +0000 (16:33 +0000)
commitd25126faae725cc2b031e9512be37aa20e383f96
tree0e4f5ff681e81d6486d9bd9deb8bd638366b8da2
parent3229c883b9446af4ae8d7d75efd62afc1976b72c
[InstCombine] Fix regression introduced at r227197.

This patch fixes a problem I accidentally introduced in an instruction combine
on select instructions added at r227197. That revision taught the instruction
combiner how to fold a cttz/ctlz followed by a icmp plus select into a single
cttz/ctlz with flag 'is_zero_undef' cleared.

However, the new rule added at r227197 would have produced wrong results in the
case where a cttz/ctlz with flag 'is_zero_undef' cleared was follwed by a
zero-extend or truncate. In that case, the folded instruction would have
been inserted in a wrong location thus leaving the CFG in an inconsistent
state.

This patch fixes the problem and add two reproducible test cases to
existing test 'InstCombine/select-cmp-cttz-ctlz.ll'.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229124 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineSelect.cpp
test/Transforms/InstCombine/select-cmp-cttz-ctlz.ll