<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [ARM] Code size bloating caused by constant hoisting"
   href="https://llvm.org/bugs/show_bug.cgi?id=28282">28282</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[ARM] Code size bloating caused by constant hoisting
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>weimingz@codeaurora.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16631" name="attach_16631" title="test cast">attachment 16631</a> <a href="attachment.cgi?id=16631&action=edit" title="test cast">[details]</a></span>
test cast

clang -Os -march=armv7m test.ll -S -o test.s

it generates large code

@ BB#0:                                 @ %entry
    .save    {r4, r5, r6, r7, r8, r9, r10, r11, lr}
    push.w    {r4, r5, r6, r7, r8, r9, r10, r11, lr}
    .pad    #4
    sub    sp, #4
    mov    r4, r1
    movs    r5, #32
    tst.w    r2, #1
    bne    .LBB0_2
@ BB#1:                                 @ %if.then12
    ldrd    lr, r3, [r0]
    rsb.w    r12, r5, #32
    ldr    r0, [r0, #8]
    rsb.w    r9, r5, #64
    sub.w    r10, r5, #64
    sub.w    r11, r5, #96
    lsl.w    r1, r3, r12
    lsr.w    r2, lr, r5
    lsl.w    r8, r0, r9
    lsr.w    r0, r0, r10
    orrs    r1, r2
    sub.w    r2, r5, #32
    cmp    r2, #0
    it    ge
    lsrge.w    r1, r3, r2
    cmp.w    r11, #0
    it    ge
    movge    r0, #0
    cmp    r5, #64
    it    lo
    orrlo.w    r0, r1, r8
    cmp    r5, #0
    it    eq
    moveq    r0, lr
    ldrd    lr, r3, [r4]
    ldr    r7, [r4, #8]
    cmp    r2, #0
    lsl.w    r6, r3, r12
    lsr.w    r1, lr, r5
    orr.w    r1, r1, r6
    it    ge
    lsrge.w    r1, r3, r2
    lsr.w    r3, r7, r10
    cmp.w    r11, #0
    lsl.w    r2, r7, r9
    it    ge
    movge    r3, #0
    cmp    r5, #64
    it    lo
    orrlo.w    r3, r1, r2
    cmp    r5, #0
    it    eq
    moveq    r3, lr
    cmp    r3, r0
    itt    ne
    movne    r0, #1
    blne    foo
.LBB0_2:                                @ %land.lhs.true39
    ldm.w    r4, {r1, r2, r3}
    rsb.w    r0, r5, #32
    lsl.w    r0, r2, r0
    lsr.w    r7, r1, r5
    orrs    r0, r7
    sub.w    r7, r5, #32
    cmp    r7, #0
    it    ge
    lsrge.w    r0, r2, r7
    rsb.w    r2, r5, #64
    sub.w    r7, r5, #64
    lsl.w    r2, r3, r2
    lsrs    r3, r7
    sub.w    r7, r5, #96
    cmp    r7, #0
    it    ge
    movge    r3, #0
    cmp    r5, #64
    it    lo
    orrlo.w    r3, r0, r2
    cmp    r5, #0
    it    eq
    moveq    r3, r1
    cmp    r3, #62
    itt    lo
    addlo    sp, #4
    poplo.w    {r4, r5, r6, r7, r8, r9, r10, r11, pc}
    movs    r0, #16
    add    sp, #4
    pop.w    {r4, r5, r6, r7, r8, r9, r10, r11, lr}
    b    foo
.Lfunc_end0:
    .size    test, .Lfunc_end0-test
    .fnend


If Hoist constant is disabled manually, the code is normal:

test:
    .fnstart
@ BB#0:                                 @ %entry
    .save    {r4, lr}
    push    {r4, lr}
    mov    r4, r1
    tst.w    r2, #1
    bne    .LBB0_2
@ BB#1:                                 @ %if.then12
    ldr    r0, [r0, #4]
    ldr    r1, [r4, #4]
    cmp    r1, r0
    itt    ne
    movne    r0, #1
    blne    foo
.LBB0_2:                                @ %land.lhs.true39
    ldr    r0, [r4, #4]
    cmp    r0, #62
    it    lo
    poplo    {r4, pc}
    movs    r0, #16
    pop.w    {r4, lr}
    b    foo
.Lfunc_end0:
    .size    test, .Lfunc_end0-test
    .fnend</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>