[IfConversion] Fix diamond conversion with unanalyzable branches.
authorEli Friedman <efriedma@quicinc.com>
Thu, 5 Sep 2019 20:02:38 +0000 (20:02 +0000)
committerEli Friedman <efriedma@quicinc.com>
Thu, 5 Sep 2019 20:02:38 +0000 (20:02 +0000)
commitcae1e47f6ed7effd82cc47e68c2a42513487a1d7
tree43f6b74a7aa2f03c96a609423567fb9eabd54f53
parent4e281f70ca598f18a99088ae10386e4a4d4d1574
[IfConversion] Fix diamond conversion with unanalyzable branches.

The code was incorrectly counting the number of identical instructions,
and therefore tried to predicate an instruction which should not have
been predicated.  This could have various effects: a compiler crash,
an assembler failure, a miscompile, or just generating an extra,
unnecessary instruction.

Instead of depending on TargetInstrInfo::removeBranch, which only
works on analyzable branches, just remove all branch instructions.

Fixes https://bugs.llvm.org/show_bug.cgi?id=43121 and
https://bugs.llvm.org/show_bug.cgi?id=41121 .

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

llvm-svn: 371111
llvm/lib/CodeGen/IfConversion.cpp
llvm/test/CodeGen/ARM/ifcvt-diamond-unanalyzable-common.mir [new file with mode: 0644]