[llvm-dev] What does isReMaterializable mean exactly?

zan jyu Wong via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 27 20:51:30 PDT 2015


Hi,
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.
Why this happend? I've try this in many backends, they seem to have the
same problem.
What exactly does `isReMaterializable = 1' mean? Does the register
allocator fail to remove useless frame objects when remating?
Any ideas? Thanks.

Cheers,
Huang

---- example function below ----

>     .globl    osc_trim_fun
>     .align    1
>     .type    osc_trim_fun,%function
>     .code    16                      @ @osc_trim_fun
>     .thumb_func
> osc_trim_fun:
>     .fnstart
> @ BB#0:
>     push.w    {r4, r5, r6, r7, r8, r9, r10, r11, lr}
>     add    r7, sp, #12
>     sub    sp, #44
>     movw    r10, :lower16:timer_cnt
>     movw    r1, :lower16:this_prd
>     movw    r2, :lower16:sof_cnt
>     movw    r3, :lower16:osc_freq
>     movw    r5, :lower16:g_pll_trimok
>     movw    lr, :lower16:sof_discard
>     movw    r0, #448
>     movw    r6, #512
>     movw    r8, #552
>     movw    r12, #244
>     movw    r9, #164
>     movs    r4, #160
>     mov.w    r11, #0
>     movt    r10, :upper16:timer_cnt
>     movt    r1, :upper16:this_prd
>     movt    r2, :upper16:sof_cnt
>     movt    r3, :upper16:osc_freq
>     movt    r5, :upper16:g_pll_trimok
>     movt    lr, :upper16:sof_discard
>     movt    r0, #7
>     movt    r6, #7
>     movt    r8, #7
>     movt    r12, #7
>     movt    r9, #7
>     movt    r4, #7
>     b    .LBB2_2
> .LBB2_1:                                @   in Loop: Header=BB2_2 Depth=1
>     mov.w    r0, #16384
>     movw    r10, :lower16:timer_cnt
>     movw    r1, :lower16:this_prd
>     movw    r2, :lower16:sof_cnt
>     movw    r3, :lower16:osc_freq
>     movw    lr, :lower16:sof_discard
>     movw    r12, #244
>     movw    r6, #512
>     movw    r9, #164
>     mov.w    r11, #0
>     str    r0, [r4]
>     movw    r0, #448
>     movt    r10, :upper16:timer_cnt
>     movt    r1, :upper16:this_prd
>     movt    r2, :upper16:sof_cnt
>     movt    r3, :upper16:osc_freq
>     movt    lr, :upper16:sof_discard
>     movt    r12, #7
>     movt    r6, #7
>     movt    r9, #7
>     movt    r0, #7
> .LBB2_2:                                @ =>This Loop Header: Depth=1
>                                         @     Child Loop BB2_3 Depth 2
>                                         @       Child Loop BB2_4 Depth 3
>                                         @     Child Loop BB2_8 Depth 2
>                                         @       Child Loop BB2_9 Depth 3
>     str.w    r11, [r1]
>     movs    r1, #2
>     str.w    r11, [r10]
>     str.w    r11, [r2]
>     str.w    r11, [r3]
>     str.w    r11, [r5]
>     strb.w    r1, [lr]
>     movs    r1, #19
>     str    r1, [r0]
>     ldr    r0, [r6]
>     bic    r0, r0, #3
>     str    r0, [r6]
>     ldr    r0, [r6]
>     orr    r0, r0, #12
>     str    r0, [r6]
>     ldr    r0, [r6]
>     bic    r0, r0, #48
>     str    r0, [r6]
>     ldr    r0, [r6]
>     bic    r0, r0, #192
>     str    r0, [r6]
>     ldr    r0, [r6]
>     orr    r0, r0, #64
>     str    r0, [r6]
>     ldr.w    r0, [r8]
>     bic    r0, r0, #16128
>     str.w    r0, [r8]
>     ldr.w    r0, [r8]
>     orr    r0, r0, #7168
>     str.w    r0, [r8]
>     movs    r0, #28
>     movt    r0, #7
>     mov    r1, r0
>     ldr    r0, [r1]
>     orr    r0, r0, #1792
>     str    r0, [r1]
>     movs    r0, #200
>     str.w    r11, [r12]
>     bl    delay
>     movw    r1, :lower16:handle_tmr3_isr
>     movs    r0, #5
>     movs    r2, #0
>     movt    r1, :upper16:handle_tmr3_isr
>     bl    HWI_Install
>     movs    r0, #180
>     movt    r0, #7
>     str.w    r11, [r0]
>     movs    r0, #184
>     movt    r0, #7
>     str.w    r11, [r0]
>     movs    r0, #176
>     movt    r0, #7
>     mov    r10, r0
>     movw    r0, #16386
>     str.w    r0, [r10]
>     bl    enable_int
>     movs    r0, #168
>     movw    r1, #1331
>     movt    r0, #7
>     str    r1, [r0]
>     movw    r0, #16385
>     str.w    r11, [r9]
>     movw    r1, #65534
>     mov    r9, r10
>     str    r0, [r4]
> .LBB2_3:                                @   Parent Loop BB2_2 Depth=1
>                                         @ =>  This Loop Header: Depth=2
>                                         @       Child Loop BB2_4 Depth 3
>     mov    r0, r1
>     ldr    r1, [r4]
>     orr    r1, r1, #16384
>     str    r1, [r4]
> .LBB2_4:                                @   Parent Loop BB2_2 Depth=1
>                                         @     Parent Loop BB2_3 Depth=2
>                                         @ =>    This Inner Loop Header:
> Depth=3
>     ldr    r1, [r4]
>     sxth    r1, r1
>     cmp    r1, #0
>     blt    .LBB2_6
> @ BB#5:                                 @   in Loop: Header=BB2_4 Depth=3
>     ldr    r1, [r5]
>     cmp    r1, #0
>     beq    .LBB2_4
>     b    .LBB2_11
> .LBB2_6:                                @ %.loopexit1
>                                         @   in Loop: Header=BB2_3 Depth=2
>     subs    r1, r0, #1
>     movw    r2, #65535
>     tst    r0, r2
>     bne    .LBB2_3
> @ BB#7:                                 @   in Loop: Header=BB2_2 Depth=1
>     ldr    r0, [r6]
>     bic    r0, r0, #64
>     str    r0, [r6]
>     bl    disable_int
>     mov.w    r0, #16384
>     movw    r1, #1791
>     str.w    r0, [r9]
> .LBB2_8:                                @   Parent Loop BB2_2 Depth=1
>                                         @ =>  This Loop Header: Depth=2
>                                         @       Child Loop BB2_9 Depth 3
>     mov    r0, r1
>     ldr    r1, [r4]
>     orr    r1, r1, #16384
>     str    r1, [r4]
> .LBB2_9:                                @   Parent Loop BB2_2 Depth=1
>                                         @     Parent Loop BB2_8 Depth=2
>                                         @ =>    This Inner Loop Header:
> Depth=3
>     ldr    r1, [r4]
>     sxth    r1, r1
>     cmp.w    r1, #-1
>     bgt    .LBB2_9
> @ BB#10:                                @ %.loopexit
>                                         @   in Loop: Header=BB2_8 Depth=2
>     subs    r1, r0, #1
>     movw    r2, #65535
>     tst    r0, r2
>     bne    .LBB2_8
>     b    .LBB2_1
> .LBB2_11:                               @ %.critedge
>     ldr    r0, [r6]
>     bic    r0, r0, #64
>     str    r0, [r6]
>     bl    disable_int
>     mov.w    r0, #16384
>     str    r0, [r4]
>     str.w    r0, [r9]
>     add    sp, #44
>     pop.w    {r4, r5, r6, r7, r8, r9, r10, r11, pc}
> .Lfunc_end2:
>     .size    osc_trim_fun, .Lfunc_end2-osc_trim_fun
>     .cantunwind
>     .fnend
>

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150828/42f7b57c/attachment.html>


More information about the llvm-dev mailing list