<div dir="ltr">Hi,<br>I compiled a function with many instructions that moves immediates. The generated code alloca space in the stack but never use it. Then I try to remove `isReMaterializable = 1' of move immediate instructions in *.td file. And generated code doesn't alloca space in stack.<br>Why this happend? I've try this in many backends, they seem to have the same problem.<br>What exactly does `isReMaterializable = 1' mean? Does the register allocator fail to remove useless frame objects when remating?<br>Any ideas? Thanks.<br><br>Cheers,<br>Huang<br><br>---- example function below ----<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">    .globl    osc_trim_fun<br>    .align    1<br>    .type    osc_trim_fun,%function<br>    .code    16                      @ @osc_trim_fun<br>    .thumb_func<br>osc_trim_fun:<br>    .fnstart<br>@ BB#0:<br>    push.w    {r4, r5, r6, r7, r8, r9, r10, r11, lr}<br>    add    r7, sp, #12<br>    sub    sp, #44<br>    movw    r10, :lower16:timer_cnt<br>    movw    r1, :lower16:this_prd<br>    movw    r2, :lower16:sof_cnt<br>    movw    r3, :lower16:osc_freq<br>    movw    r5, :lower16:g_pll_trimok<br>    movw    lr, :lower16:sof_discard<br>    movw    r0, #448<br>    movw    r6, #512<br>    movw    r8, #552<br>    movw    r12, #244<br>    movw    r9, #164<br>    movs    r4, #160<br>    mov.w    r11, #0<br>    movt    r10, :upper16:timer_cnt<br>    movt    r1, :upper16:this_prd<br>    movt    r2, :upper16:sof_cnt<br>    movt    r3, :upper16:osc_freq<br>    movt    r5, :upper16:g_pll_trimok<br>    movt    lr, :upper16:sof_discard<br>    movt    r0, #7<br>    movt    r6, #7<br>    movt    r8, #7<br>    movt    r12, #7<br>    movt    r9, #7<br>    movt    r4, #7<br>    b    .LBB2_2<br>.LBB2_1:                                @   in Loop: Header=BB2_2 Depth=1<br>    mov.w    r0, #16384<br>    movw    r10, :lower16:timer_cnt<br>    movw    r1, :lower16:this_prd<br>    movw    r2, :lower16:sof_cnt<br>    movw    r3, :lower16:osc_freq<br>    movw    lr, :lower16:sof_discard<br>    movw    r12, #244<br>    movw    r6, #512<br>    movw    r9, #164<br>    mov.w    r11, #0<br>    str    r0, [r4]<br>    movw    r0, #448<br>    movt    r10, :upper16:timer_cnt<br>    movt    r1, :upper16:this_prd<br>    movt    r2, :upper16:sof_cnt<br>    movt    r3, :upper16:osc_freq<br>    movt    lr, :upper16:sof_discard<br>    movt    r12, #7<br>    movt    r6, #7<br>    movt    r9, #7<br>    movt    r0, #7<br>.LBB2_2:                                @ =>This Loop Header: Depth=1<br>                                        @     Child Loop BB2_3 Depth 2<br>                                        @       Child Loop BB2_4 Depth 3<br>                                        @     Child Loop BB2_8 Depth 2<br>                                        @       Child Loop BB2_9 Depth 3<br>    str.w    r11, [r1]<br>    movs    r1, #2<br>    str.w    r11, [r10]<br>    str.w    r11, [r2]<br>    str.w    r11, [r3]<br>    str.w    r11, [r5]<br>    strb.w    r1, [lr]<br>    movs    r1, #19<br>    str    r1, [r0]<br>    ldr    r0, [r6]<br>    bic    r0, r0, #3<br>    str    r0, [r6]<br>    ldr    r0, [r6]<br>    orr    r0, r0, #12<br>    str    r0, [r6]<br>    ldr    r0, [r6]<br>    bic    r0, r0, #48<br>    str    r0, [r6]<br>    ldr    r0, [r6]<br>    bic    r0, r0, #192<br>    str    r0, [r6]<br>    ldr    r0, [r6]<br>    orr    r0, r0, #64<br>    str    r0, [r6]<br>    ldr.w    r0, [r8]<br>    bic    r0, r0, #16128<br>    str.w    r0, [r8]<br>    ldr.w    r0, [r8]<br>    orr    r0, r0, #7168<br>    str.w    r0, [r8]<br>    movs    r0, #28<br>    movt    r0, #7<br>    mov    r1, r0<br>    ldr    r0, [r1]<br>    orr    r0, r0, #1792<br>    str    r0, [r1]<br>    movs    r0, #200<br>    str.w    r11, [r12]<br>    bl    delay<br>    movw    r1, :lower16:handle_tmr3_isr<br>    movs    r0, #5<br>    movs    r2, #0<br>    movt    r1, :upper16:handle_tmr3_isr<br>    bl    HWI_Install<br>    movs    r0, #180<br>    movt    r0, #7<br>    str.w    r11, [r0]<br>    movs    r0, #184<br>    movt    r0, #7<br>    str.w    r11, [r0]<br>    movs    r0, #176<br>    movt    r0, #7<br>    mov    r10, r0<br>    movw    r0, #16386<br>    str.w    r0, [r10]<br>    bl    enable_int<br>    movs    r0, #168<br>    movw    r1, #1331<br>    movt    r0, #7<br>    str    r1, [r0]<br>    movw    r0, #16385<br>    str.w    r11, [r9]<br>    movw    r1, #65534<br>    mov    r9, r10<br>    str    r0, [r4]<br>.LBB2_3:                                @   Parent Loop BB2_2 Depth=1<br>                                        @ =>  This Loop Header: Depth=2<br>                                        @       Child Loop BB2_4 Depth 3<br>    mov    r0, r1<br>    ldr    r1, [r4]<br>    orr    r1, r1, #16384<br>    str    r1, [r4]<br>.LBB2_4:                                @   Parent Loop BB2_2 Depth=1<br>                                        @     Parent Loop BB2_3 Depth=2<br>                                        @ =>    This Inner Loop Header: Depth=3<br>    ldr    r1, [r4]<br>    sxth    r1, r1<br>    cmp    r1, #0<br>    blt    .LBB2_6<br>@ BB#5:                                 @   in Loop: Header=BB2_4 Depth=3<br>    ldr    r1, [r5]<br>    cmp    r1, #0<br>    beq    .LBB2_4<br>    b    .LBB2_11<br>.LBB2_6:                                @ %.loopexit1<br>                                        @   in Loop: Header=BB2_3 Depth=2<br>    subs    r1, r0, #1<br>    movw    r2, #65535<br>    tst    r0, r2<br>    bne    .LBB2_3<br>@ BB#7:                                 @   in Loop: Header=BB2_2 Depth=1<br>    ldr    r0, [r6]<br>    bic    r0, r0, #64<br>    str    r0, [r6]<br>    bl    disable_int<br>    mov.w    r0, #16384<br>    movw    r1, #1791<br>    str.w    r0, [r9]<br>.LBB2_8:                                @   Parent Loop BB2_2 Depth=1<br>                                        @ =>  This Loop Header: Depth=2<br>                                        @       Child Loop BB2_9 Depth 3<br>    mov    r0, r1<br>    ldr    r1, [r4]<br>    orr    r1, r1, #16384<br>    str    r1, [r4]<br>.LBB2_9:                                @   Parent Loop BB2_2 Depth=1<br>                                        @     Parent Loop BB2_8 Depth=2<br>                                        @ =>    This Inner Loop Header: Depth=3<br>    ldr    r1, [r4]<br>    sxth    r1, r1<br>    cmp.w    r1, #-1<br>    bgt    .LBB2_9<br>@ BB#10:                                @ %.loopexit<br>                                        @   in Loop: Header=BB2_8 Depth=2<br>    subs    r1, r0, #1<br>    movw    r2, #65535<br>    tst    r0, r2<br>    bne    .LBB2_8<br>    b    .LBB2_1<br>.LBB2_11:                               @ %.critedge<br>    ldr    r0, [r6]<br>    bic    r0, r0, #64<br>    str    r0, [r6]<br>    bl    disable_int<br>    mov.w    r0, #16384<br>    str    r0, [r4]<br>    str.w    r0, [r9]<br>    add    sp, #44<br>    pop.w    {r4, r5, r6, r7, r8, r9, r10, r11, pc}<br>.Lfunc_end2:<br>    .size    osc_trim_fun, .Lfunc_end2-osc_trim_fun<br>    .cantunwind<br>    .fnend<br></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><br></blockquote></div>