[CodeGen][IfCvt] Don't re-ifcvt blocks with unanalyzable terminators.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Sat, 21 Mar 2015 01:23:15 +0000 (01:23 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Sat, 21 Mar 2015 01:23:15 +0000 (01:23 +0000)
commit7173b669b47fecc0570846ac37b7809f1e6550ed
treedd586f438bcc6079ea4c1a245d1a9aac5bc4e42b
parente6bb09ac3f15c481f8f3cda71e46ed1133c21bd4
[CodeGen][IfCvt] Don't re-ifcvt blocks with unanalyzable terminators.

If we couldn't analyze its terminator (i.e., it's an indirectbr, or some
other weirdness), we can't safely re-if-convert a predicated block,
because we can't tell whether the predicated terminator can
fallthrough (it does).

Currently, we would completely ignore the fallthrough successor. In
the added testcase, this means we used to generate:

    ...
  @ %entry:
    cmp   r5, #21
    ittt  ne
  @ %cc1f:
    cmpne r7, #42
  @ %cc2t:
    strne.w       r5, [r8]
    movne pc, r10
  @ %cc1t:
    ...

Whereas the successor of %cc1f was originally %bb1.
With the fix, we get the correct:

    ...
  @ %entry:
    cmp   r5, #21
    itt   eq
  @ %cc1t:
    streq.w       r5, [r11]
    moveq pc, r0
  @ %cc1f:
    cmp   r7, #42
    itt   ne
  @ %cc2t:
    strne.w       r5, [r8]
    movne pc, r10
  @ %bb1:
    ...

rdar://20192768
Differential Revision: http://reviews.llvm.org/D8509

llvm-svn: 232872
llvm/lib/CodeGen/IfConversion.cpp
llvm/test/CodeGen/ARM/ifcvt-iter-indbr.ll [new file with mode: 0644]