# Test 32-bit COMPARE IMMEDIATE AND BRANCH in cases where the sheer number of
# instructions causes some branches to be out of range.
# RUN: %python %s | llc -mtriple=s390x-linux-gnu | FileCheck %s
# Construct:
#
# before0:
# conditional branch to after0
# ...
# beforeN:
# conditional branch to after0
# main:
# 0xffcc bytes, from MVIY instructions
# conditional branch to main
# after0:
# ...
# conditional branch to main
# afterN:
#
# Each conditional branch sequence occupies 12 bytes if it uses a short
# branch and 16 if it uses a long one. The ones before "main:" have to
# take the branch length into account, which is 6 for short branches,
# so the final (0x34 - 6) / 12 == 3 blocks can use short branches.
# The ones after "main:" do not, so the first 0x34 / 12 == 4 blocks
# can use short branches. The conservative algorithm we use makes
# one of the forward branches unnecessarily long, as noted in the
# check output below.
#
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: chi [[REG]], 50
# CHECK: jgl [[LABEL:\.L[^ ]*]]
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: chi [[REG]], 51
# CHECK: jgl [[LABEL]]
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: chi [[REG]], 52
# CHECK: jgl [[LABEL]]
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: chi [[REG]], 53
# CHECK: jgl [[LABEL]]
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: chi [[REG]], 54
# CHECK: jgl [[LABEL]]
# ...as mentioned above, the next one could be a CIJL instead...
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: chi [[REG]], 55
# CHECK: jgl [[LABEL]]
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: cijl [[REG]], 56, [[LABEL]]
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: cijl [[REG]], 57, [[LABEL]]
# ...main goes here...
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: cijl [[REG]], 100, [[LABEL:\.L[^ ]*]]
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: cijl [[REG]], 101, [[LABEL]]
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: cijl [[REG]], 102, [[LABEL]]
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: cijl [[REG]], 103, [[LABEL]]
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: chi [[REG]], 104
# CHECK: jgl [[LABEL]]
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: chi [[REG]], 105
# CHECK: jgl [[LABEL]]
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: chi [[REG]], 106
# CHECK: jgl [[LABEL]]
# CHECK: lb [[REG:%r[0-5]]], 0(%r3)
# CHECK: chi [[REG]], 107
# CHECK: jgl [[LABEL]]
= 8
= 0xffcc
= %
, = 1, 1
, = , +
= 4096 + % 500000
= % 256