Home | History | Annotate | Download | only in Large
      1 # Test normal conditional branches in cases where block alignments cause
      2 # some branches to be out of range.
      3 # RUN: python %s | llc -mtriple=s390x-linux-gnu -align-all-blocks=8 | FileCheck %s
      4 
      5 # Construct:
      6 #
      7 # b0:
      8 #   conditional branch to end
      9 #   ...
     10 # b<N>:
     11 #   conditional branch to end
     12 # b<N+1>:
     13 #   conditional branch to b0
     14 #   ...
     15 # b<2*N>:
     16 #   conditional branch to b0
     17 # end:
     18 #
     19 # with N == 256 + 4.  The -align-all-blocks=8 option ensures that all blocks
     20 # are 256 bytes in size.  The first 4 blocks and the last 4 blocks are then
     21 # out of range.
     22 #
     23 # CHECK: c %r4, 0(%r3)
     24 # CHECK: jge [[LABEL:\.L[^ ]*]]
     25 # CHECK: c %r4, 4(%r3)
     26 # CHECK: jge [[LABEL]]
     27 # CHECK: c %r4, 8(%r3)
     28 # CHECK: jge [[LABEL]]
     29 # CHECK: c %r4, 12(%r3)
     30 # CHECK: jge [[LABEL]]
     31 # CHECK: c %r4, 16(%r3)
     32 # CHECK: je [[LABEL]]
     33 # CHECK: c %r4, 20(%r3)
     34 # CHECK: je [[LABEL]]
     35 # CHECK: c %r4, 24(%r3)
     36 # CHECK: je [[LABEL]]
     37 # CHECK: c %r4, 28(%r3)
     38 # CHECK: je [[LABEL]]
     39 # ...lots of other blocks...
     40 # CHECK: c %r4, 1004(%r3)
     41 # CHECK: je [[LABEL:\.L[^ ]*]]
     42 # CHECK: c %r4, 1008(%r3)
     43 # CHECK: je [[LABEL]]
     44 # CHECK: c %r4, 1012(%r3)
     45 # CHECK: je [[LABEL]]
     46 # CHECK: c %r4, 1016(%r3)
     47 # CHECK: je [[LABEL]]
     48 # CHECK: c %r4, 1020(%r3)
     49 # CHECK: je [[LABEL]]
     50 # CHECK: c %r4, 1024(%r3)
     51 # CHECK: jge [[LABEL]]
     52 # CHECK: c %r4, 1028(%r3)
     53 # CHECK: jge [[LABEL]]
     54 # CHECK: c %r4, 1032(%r3)
     55 # CHECK: jge [[LABEL]]
     56 # CHECK: c %r4, 1036(%r3)
     57 # CHECK: jge [[LABEL]]
     58 
     59 blocks = 256 + 4
     60 
     61 print 'define void @f1(i8 *%base, i32 *%stop, i32 %limit) {'
     62 print 'entry:'
     63 print '  br label %b0'
     64 print ''
     65 
     66 a, b = 1, 1
     67 for i in xrange(blocks):
     68     a, b = b, a + b
     69     value = a % 256
     70     next = 'b%d' % (i + 1) if i + 1 < blocks else 'end'
     71     other = 'end' if 2 * i < blocks else 'b0'
     72     print 'b%d:' % i
     73     print '  store volatile i8 %d, i8 *%%base' % value
     74     print '  %%astop%d = getelementptr i32 *%%stop, i64 %d' % (i, i)
     75     print '  %%acur%d = load volatile i32 *%%astop%d' % (i, i)
     76     print '  %%atest%d = icmp eq i32 %%limit, %%acur%d' % (i, i)
     77     print '  br i1 %%atest%d, label %%%s, label %%%s' % (i, other, next)
     78 
     79 print ''
     80 print '%s:' % next
     81 print '  ret void'
     82 print '}'
     83