brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.7 KiB · 8eccfe6 Raw
234 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 22; RUN: llc %s -o - -enable-shrink-wrap=true | FileCheck %s --check-prefix=ENABLE3; RUN: llc %s -o - -enable-shrink-wrap=false | FileCheck %s --check-prefix=DISABLE4 5target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"6target triple = "x86_64--windows-gnu"7 8; The output of this function with or without shrink-wrapping9; shouldn't change.10; Indeed, the epilogue block would have been if.else, meaning11; after the pops, we will have additional instruction (jump, mov,12; etc.) prior to the return and this is forbidden for Win64.13define i32 @loopInfoSaveOutsideLoop(i32 %cond, i32 %N) #0 {14; ENABLE-LABEL: loopInfoSaveOutsideLoop:15; ENABLE:       # %bb.0: # %entry16; ENABLE-NEXT:    pushq %rbx17; ENABLE-NEXT:    .seh_pushreg %rbx18; ENABLE-NEXT:    .seh_endprologue19; ENABLE-NEXT:    testl %ecx, %ecx20; ENABLE-NEXT:    je .LBB0_521; ENABLE-NEXT:  # %bb.1: # %for.preheader22; ENABLE-NEXT:    #APP23; ENABLE-NEXT:    nop24; ENABLE-NEXT:    #NO_APP25; ENABLE-NEXT:    xorl %eax, %eax26; ENABLE-NEXT:    movl $10, %ecx27; ENABLE-NEXT:    .p2align 428; ENABLE-NEXT:  .LBB0_2: # %for.body29; ENABLE-NEXT:    # =>This Inner Loop Header: Depth=130; ENABLE-NEXT:    #APP31; ENABLE-NEXT:    movl $1, %edx32; ENABLE-NEXT:    #NO_APP33; ENABLE-NEXT:    addl %edx, %eax34; ENABLE-NEXT:    decl %ecx35; ENABLE-NEXT:    jne .LBB0_236; ENABLE-NEXT:  # %bb.3: # %for.end37; ENABLE-NEXT:    #APP38; ENABLE-NEXT:    nop39; ENABLE-NEXT:    #NO_APP40; ENABLE-NEXT:    shll $3, %eax41; ENABLE-NEXT:    .seh_startepilogue42; ENABLE-NEXT:    popq %rbx43; ENABLE-NEXT:    .seh_endepilogue44; ENABLE-NEXT:    retq45; ENABLE-NEXT:  .LBB0_5: # %if.else46; ENABLE-NEXT:    movl %edx, %eax47; ENABLE-NEXT:    addl %edx, %eax48; ENABLE-NEXT:    .seh_startepilogue49; ENABLE-NEXT:    popq %rbx50; ENABLE-NEXT:    .seh_endepilogue51; ENABLE-NEXT:    retq52; ENABLE-NEXT:    .seh_endproc53;54; DISABLE-LABEL: loopInfoSaveOutsideLoop:55; DISABLE:       # %bb.0: # %entry56; DISABLE-NEXT:    pushq %rbx57; DISABLE-NEXT:    .seh_pushreg %rbx58; DISABLE-NEXT:    .seh_endprologue59; DISABLE-NEXT:    testl %ecx, %ecx60; DISABLE-NEXT:    je .LBB0_561; DISABLE-NEXT:  # %bb.1: # %for.preheader62; DISABLE-NEXT:    #APP63; DISABLE-NEXT:    nop64; DISABLE-NEXT:    #NO_APP65; DISABLE-NEXT:    xorl %eax, %eax66; DISABLE-NEXT:    movl $10, %ecx67; DISABLE-NEXT:    .p2align 468; DISABLE-NEXT:  .LBB0_2: # %for.body69; DISABLE-NEXT:    # =>This Inner Loop Header: Depth=170; DISABLE-NEXT:    #APP71; DISABLE-NEXT:    movl $1, %edx72; DISABLE-NEXT:    #NO_APP73; DISABLE-NEXT:    addl %edx, %eax74; DISABLE-NEXT:    decl %ecx75; DISABLE-NEXT:    jne .LBB0_276; DISABLE-NEXT:  # %bb.3: # %for.end77; DISABLE-NEXT:    #APP78; DISABLE-NEXT:    nop79; DISABLE-NEXT:    #NO_APP80; DISABLE-NEXT:    shll $3, %eax81; DISABLE-NEXT:    .seh_startepilogue82; DISABLE-NEXT:    popq %rbx83; DISABLE-NEXT:    .seh_endepilogue84; DISABLE-NEXT:    retq85; DISABLE-NEXT:  .LBB0_5: # %if.else86; DISABLE-NEXT:    movl %edx, %eax87; DISABLE-NEXT:    addl %edx, %eax88; DISABLE-NEXT:    .seh_startepilogue89; DISABLE-NEXT:    popq %rbx90; DISABLE-NEXT:    .seh_endepilogue91; DISABLE-NEXT:    retq92; DISABLE-NEXT:    .seh_endproc93entry:94  %tobool = icmp eq i32 %cond, 095  br i1 %tobool, label %if.else, label %for.preheader96 97for.preheader:                                    ; preds = %entry98  tail call void asm "nop", ""()99  br label %for.body100 101for.body:                                         ; preds = %for.body, %for.preheader102  %i.05 = phi i32 [ %inc, %for.body ], [ 0, %for.preheader ]103  %sum.04 = phi i32 [ %add, %for.body ], [ 0, %for.preheader ]104  %call = tail call i32 asm "movl $$1, $0", "=r,~{ebx}"()105  %add = add nsw i32 %call, %sum.04106  %inc = add nuw nsw i32 %i.05, 1107  %exitcond = icmp eq i32 %inc, 10108  br i1 %exitcond, label %for.end, label %for.body109 110for.end:                                          ; preds = %for.body111  tail call void asm "nop", "~{ebx}"()112  %shl = shl i32 %add, 3113  br label %if.end114 115if.else:                                          ; preds = %entry116  %mul = shl nsw i32 %N, 1117  br label %if.end118 119if.end:                                           ; preds = %if.else, %for.end120  %sum.1 = phi i32 [ %shl, %for.end ], [ %mul, %if.else ]121  ret i32 %sum.1122}123 124; When we can sink the epilogue of the function into an existing exit block,125; this is Ok for shrink-wrapping to kicks in.126define i32 @loopInfoSaveOutsideLoop2(i32 %cond, i32 %N) #0 {127; ENABLE-LABEL: loopInfoSaveOutsideLoop2:128; ENABLE:       # %bb.0: # %entry129; ENABLE-NEXT:    testl %ecx, %ecx130; ENABLE-NEXT:    je .LBB1_4131; ENABLE-NEXT:  # %bb.1: # %for.preheader132; ENABLE-NEXT:    pushq %rbx133; ENABLE-NEXT:    .seh_pushreg %rbx134; ENABLE-NEXT:    .seh_endprologue135; ENABLE-NEXT:    #APP136; ENABLE-NEXT:    nop137; ENABLE-NEXT:    #NO_APP138; ENABLE-NEXT:    xorl %eax, %eax139; ENABLE-NEXT:    movl $10, %ecx140; ENABLE-NEXT:    .p2align 4141; ENABLE-NEXT:  .LBB1_2: # %for.body142; ENABLE-NEXT:    # =>This Inner Loop Header: Depth=1143; ENABLE-NEXT:    #APP144; ENABLE-NEXT:    movl $1, %edx145; ENABLE-NEXT:    #NO_APP146; ENABLE-NEXT:    addl %edx, %eax147; ENABLE-NEXT:    decl %ecx148; ENABLE-NEXT:    jne .LBB1_2149; ENABLE-NEXT:  # %bb.3: # %for.end150; ENABLE-NEXT:    #APP151; ENABLE-NEXT:    nop152; ENABLE-NEXT:    #NO_APP153; ENABLE-NEXT:    shll $3, %eax154; ENABLE-NEXT:    .seh_startepilogue155; ENABLE-NEXT:    popq %rbx156; ENABLE-NEXT:    .seh_endepilogue157; ENABLE-NEXT:    retq158; ENABLE-NEXT:  .LBB1_4: # %if.else159; ENABLE-NEXT:    addl %edx, %edx160; ENABLE-NEXT:    movl %edx, %eax161; ENABLE-NEXT:    retq162; ENABLE-NEXT:    .seh_endproc163;164; DISABLE-LABEL: loopInfoSaveOutsideLoop2:165; DISABLE:       # %bb.0: # %entry166; DISABLE-NEXT:    pushq %rbx167; DISABLE-NEXT:    .seh_pushreg %rbx168; DISABLE-NEXT:    .seh_endprologue169; DISABLE-NEXT:    testl %ecx, %ecx170; DISABLE-NEXT:    je .LBB1_5171; DISABLE-NEXT:  # %bb.1: # %for.preheader172; DISABLE-NEXT:    #APP173; DISABLE-NEXT:    nop174; DISABLE-NEXT:    #NO_APP175; DISABLE-NEXT:    xorl %eax, %eax176; DISABLE-NEXT:    movl $10, %ecx177; DISABLE-NEXT:    .p2align 4178; DISABLE-NEXT:  .LBB1_2: # %for.body179; DISABLE-NEXT:    # =>This Inner Loop Header: Depth=1180; DISABLE-NEXT:    #APP181; DISABLE-NEXT:    movl $1, %edx182; DISABLE-NEXT:    #NO_APP183; DISABLE-NEXT:    addl %edx, %eax184; DISABLE-NEXT:    decl %ecx185; DISABLE-NEXT:    jne .LBB1_2186; DISABLE-NEXT:  # %bb.3: # %for.end187; DISABLE-NEXT:    #APP188; DISABLE-NEXT:    nop189; DISABLE-NEXT:    #NO_APP190; DISABLE-NEXT:    shll $3, %eax191; DISABLE-NEXT:    .seh_startepilogue192; DISABLE-NEXT:    popq %rbx193; DISABLE-NEXT:    .seh_endepilogue194; DISABLE-NEXT:    retq195; DISABLE-NEXT:  .LBB1_5: # %if.else196; DISABLE-NEXT:    addl %edx, %edx197; DISABLE-NEXT:    movl %edx, %eax198; DISABLE-NEXT:    .seh_startepilogue199; DISABLE-NEXT:    popq %rbx200; DISABLE-NEXT:    .seh_endepilogue201; DISABLE-NEXT:    retq202; DISABLE-NEXT:    .seh_endproc203entry:204  %tobool = icmp eq i32 %cond, 0205  br i1 %tobool, label %if.else, label %for.preheader206 207for.preheader:                                    ; preds = %entry208  tail call void asm "nop", ""()209  br label %for.body210 211for.body:                                         ; preds = %for.body, %for.preheader212  %i.05 = phi i32 [ %inc, %for.body ], [ 0, %for.preheader ]213  %sum.04 = phi i32 [ %add, %for.body ], [ 0, %for.preheader ]214  %call = tail call i32 asm sideeffect "movl $$1, $0", "=r,~{ebx}"()215  %add = add nsw i32 %call, %sum.04216  %inc = add nuw nsw i32 %i.05, 1217  %exitcond = icmp eq i32 %inc, 10218  br i1 %exitcond, label %for.end, label %for.body219 220for.end:                                          ; preds = %for.body221  tail call void asm "nop", "~{ebx}"()222  %shl = shl i32 %add, 3223  ret i32 %shl224 225if.else:                                          ; preds = %entry226  %mul = shl nsw i32 %N, 1227  br label %if.end228 229if.end:                                           ; preds = %if.else, %for.end230  ret i32 %mul231}232 233attributes #0 = { uwtable }234