[SystemZ] Fix thinko in long branch pass
authorRichard Sandiford <rsandifo@linux.vnet.ibm.com>
Wed, 22 May 2013 09:57:57 +0000 (09:57 +0000)
committerRichard Sandiford <rsandifo@linux.vnet.ibm.com>
Wed, 22 May 2013 09:57:57 +0000 (09:57 +0000)
commit487399a60f9e4e8263317038d779caa6b68ea61a
treed06f1118d2709580144fa0799bdf9166423462bc
parent3b4b5367da29a1598dc333acf37652ef286e9225
[SystemZ] Fix thinko in long branch pass

The original version of the pass could underestimate the length of a backward
branch in cases like:

    alignment to N bytes or more
    ...
    relaxable branch A
    ...
 foo: (aligned to M<N bytes)
    ...
 bar: (aligned to N bytes)
    ...
    relaxable branch B to foo

We don't add any misalignment gap for "bar" because N bytes of alignment
had already been reached earlier in the function.  In this case, assuming
that A is relaxed can push "foo" closer to "bar", and make B appear to be
in range.  Similar problems can occur for forward branches.

I don't think it's possible to create blocks with mixed alignments as
things stand, not least because we haven't yet defined getPrefLoopAlignment()
for SystemZ (that would need benchmarking).  So I don't think we can test
this yet.

Thanks to Rafael EspĂ­ndola for spotting the bug.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182460 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/SystemZ/SystemZLongBranch.cpp