[LegalizeDAG] Handle NeedInvert when expanding BR_CC
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Fri, 15 Jan 2021 09:35:56 +0000 (10:35 +0100)
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Sat, 16 Jan 2021 13:33:19 +0000 (14:33 +0100)
commit4f155567317d3187bc18be866b3f3b5352f1bfa5
treee4f660c643185ebe6da73982827bfaffc514f86a
parentdbe056c2e37f00b9f33ab63bba73dbb004e13562
[LegalizeDAG] Handle NeedInvert when expanding BR_CC

This is a follow-up fix to commit 03c8d6a0c4bd0016bdfd1e5.
Seems like we now end up with NeedInvert being set in the result
from LegalizeSetCCCondCode more often than in the past, so we
need to handle NeedInvert when expanding BR_CC.

Not sure how to deal with the "Tmp4.getNode()" case properly,
but current assumption is that that code path isn't impacted
by the changes in 03c8d6a0c4bd0016bdfd1e5 so we can simply move
the old assert into the if-branch and only handle NeedInvert in the
else-branch.

I think that the test case added here, for PowerPC, might have
failed also before commit 03c8d6a0c4bd0016bdfd1e5. But we started
to hit the assert more often downstream when having merged that
commit.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D94762
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/test/CodeGen/PowerPC/legalize-invert-br_cc.ll [new file with mode: 0644]