|
| 1 | +# NOTE: This test verifies disable/enable instruction hoisting to hot blocks based on non-profile data |
| 2 | +# RUN: llc -run-pass early-machinelicm -disable-hoisting-to-hotter-blocks=all -block-freq-ratio-threshold=100 %s -o - | FileCheck %s --check-prefix=CHECK-NO-HOIST |
| 3 | +# RUN: llc -run-pass early-machinelicm -disable-hoisting-to-hotter-blocks=all -block-freq-ratio-threshold=100000000 %s -o - | FileCheck %s --check-prefix=CHECK-HOIST |
| 4 | +# RUN: llc -run-pass early-machinelicm -disable-hoisting-to-hotter-blocks=pgo -block-freq-ratio-threshold=100 %s -o - | FileCheck %s --check-prefix=CHECK-HOIST |
| 5 | +# RUN: llc -run-pass early-machinelicm -disable-hoisting-to-hotter-blocks=none -block-freq-ratio-threshold=100 %s -o - | FileCheck %s --check-prefix=CHECK-HOIST |
| 6 | + |
| 7 | +--- | |
| 8 | + target datalayout = "e-m:e-i64:64-n32:64" |
| 9 | + |
| 10 | + define dso_local void @test(void (i32)* nocapture %fp, i32 signext %Arg, i32 signext %Len, i32* nocapture %Ptr) { |
| 11 | + entry: |
| 12 | + tail call void asm sideeffect "#NOTHING", "~{r2}"() |
| 13 | + %cmp6 = icmp sgt i32 %Len, 0 |
| 14 | + br i1 %cmp6, label %for.body.lr.ph, label %for.cond.cleanup |
| 15 | + |
| 16 | + for.body.lr.ph: ; preds = %entry |
| 17 | + %cmp1 = icmp sgt i32 %Arg, 10 |
| 18 | + br label %for.body |
| 19 | + |
| 20 | + for.cond.cleanup: ; preds = %for.inc, %entry |
| 21 | + ret void |
| 22 | + |
| 23 | + for.body: ; preds = %for.inc, %for.body.lr.ph |
| 24 | + %i.07 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ] |
| 25 | + %0 = load i32, i32* %Ptr, align 4 |
| 26 | + %1 = add i32 %i.07, %0 |
| 27 | + store i32 %1, i32* %Ptr, align 4 |
| 28 | + br i1 %cmp1, label %if.then, label %for.inc |
| 29 | + |
| 30 | + if.then: ; preds = %for.body |
| 31 | + tail call void asm sideeffect "#NOTHING", "~{r2}"() |
| 32 | + tail call void %fp(i32 signext %Arg) |
| 33 | + br label %for.inc |
| 34 | + |
| 35 | + for.inc: ; preds = %if.then, %for.body |
| 36 | + %inc = add nuw nsw i32 %i.07, 1 |
| 37 | + %exitcond = icmp eq i32 %Len, %inc |
| 38 | + br i1 %exitcond, label %for.cond.cleanup, label %for.body |
| 39 | + } |
| 40 | + |
| 41 | + ; Function Attrs: nounwind |
| 42 | + declare void @llvm.stackprotector(i8*, i8**) #0 |
| 43 | + |
| 44 | + attributes #0 = { nounwind } |
| 45 | + |
| 46 | +... |
| 47 | +--- |
| 48 | +name: test |
| 49 | +alignment: 4 |
| 50 | +exposesReturnsTwice: false |
| 51 | +legalized: false |
| 52 | +regBankSelected: false |
| 53 | +selected: false |
| 54 | +failedISel: false |
| 55 | +tracksRegLiveness: true |
| 56 | +hasWinCFI: false |
| 57 | +registers: |
| 58 | + - { id: 0, class: crbitrc, preferred-register: '' } |
| 59 | + - { id: 1, class: gprc_and_gprc_nor0, preferred-register: '' } |
| 60 | + - { id: 2, class: gprc, preferred-register: '' } |
| 61 | + - { id: 3, class: g8rc, preferred-register: '' } |
| 62 | + - { id: 4, class: g8rc, preferred-register: '' } |
| 63 | + - { id: 5, class: g8rc, preferred-register: '' } |
| 64 | + - { id: 6, class: g8rc_and_g8rc_nox0, preferred-register: '' } |
| 65 | + - { id: 7, class: gprc, preferred-register: '' } |
| 66 | + - { id: 8, class: gprc, preferred-register: '' } |
| 67 | + - { id: 9, class: crrc, preferred-register: '' } |
| 68 | + - { id: 10, class: gprc, preferred-register: '' } |
| 69 | + - { id: 11, class: crrc, preferred-register: '' } |
| 70 | + - { id: 12, class: gprc, preferred-register: '' } |
| 71 | + - { id: 13, class: gprc, preferred-register: '' } |
| 72 | + - { id: 14, class: g8rc, preferred-register: '' } |
| 73 | + - { id: 15, class: g8rc, preferred-register: '' } |
| 74 | + - { id: 16, class: crrc, preferred-register: '' } |
| 75 | +liveins: |
| 76 | + - { reg: '$x3', virtual-reg: '%3' } |
| 77 | + - { reg: '$x4', virtual-reg: '%4' } |
| 78 | + - { reg: '$x5', virtual-reg: '%5' } |
| 79 | + - { reg: '$x6', virtual-reg: '%6' } |
| 80 | +frameInfo: |
| 81 | + isFrameAddressTaken: false |
| 82 | + isReturnAddressTaken: false |
| 83 | + hasStackMap: false |
| 84 | + hasPatchPoint: false |
| 85 | + stackSize: 0 |
| 86 | + offsetAdjustment: 0 |
| 87 | + maxAlignment: 0 |
| 88 | + adjustsStack: false |
| 89 | + hasCalls: true |
| 90 | + stackProtector: '' |
| 91 | + maxCallFrameSize: 4294967295 |
| 92 | + cvBytesOfCalleeSavedRegisters: 0 |
| 93 | + hasOpaqueSPAdjustment: false |
| 94 | + hasVAStart: false |
| 95 | + hasMustTailInVarArgFunc: false |
| 96 | + localFrameSize: 0 |
| 97 | + savePoint: '' |
| 98 | + restorePoint: '' |
| 99 | +fixedStack: [] |
| 100 | +stack: [] |
| 101 | +constants: [] |
| 102 | +machineFunctionInfo: {} |
| 103 | +body: | |
| 104 | + bb.0.entry: |
| 105 | + successors: %bb.1(0x7ecade30), %bb.2(0x013521d0) |
| 106 | + liveins: $x3, $x4, $x5, $x6 |
| 107 | +
|
| 108 | + %6:g8rc_and_g8rc_nox0 = COPY $x6 |
| 109 | + %5:g8rc = COPY $x5 |
| 110 | + %4:g8rc = COPY $x4 |
| 111 | + %3:g8rc = COPY $x3 |
| 112 | + %7:gprc = COPY %4.sub_32 |
| 113 | + %8:gprc = COPY %5.sub_32 |
| 114 | + INLINEASM &"#NOTHING", 1, 12, implicit-def early-clobber $r2 |
| 115 | + %9:crrc = CMPWI %8, 1 |
| 116 | + BCC 12, killed %9, %bb.2 |
| 117 | + B %bb.1 |
| 118 | +
|
| 119 | + bb.1.for.body.lr.ph: |
| 120 | + successors: %bb.3(0x80000000) |
| 121 | +
|
| 122 | + %11:crrc = CMPWI %7, 10 |
| 123 | + %0:crbitrc = COPY %11.sub_gt |
| 124 | + %10:gprc = LI 0 |
| 125 | + B %bb.3 |
| 126 | +
|
| 127 | + bb.2.for.cond.cleanup: |
| 128 | + BLR8 implicit $lr8, implicit $rm |
| 129 | +
|
| 130 | + bb.3.for.body: |
| 131 | + successors: %bb.4(0x00000002), %bb.5(0x7ffffffe) |
| 132 | +
|
| 133 | + %1:gprc_and_gprc_nor0 = PHI %10, %bb.1, %2, %bb.5 |
| 134 | + %12:gprc = LWZ 0, %6 :: (load 4 from %ir.Ptr) |
| 135 | + %13:gprc = ADD4 %1, killed %12 |
| 136 | + STW killed %13, 0, %6 :: (store 4 into %ir.Ptr) |
| 137 | + BCn %0, %bb.5 |
| 138 | + B %bb.4 |
| 139 | +
|
| 140 | + bb.4.if.then: |
| 141 | + successors: %bb.5(0x80000000) |
| 142 | +
|
| 143 | + INLINEASM &"#NOTHING", 1, 12, implicit-def early-clobber $r2 |
| 144 | + ADJCALLSTACKDOWN 32, 0, implicit-def dead $r1, implicit $r1 |
| 145 | + %14:g8rc = COPY $x2 |
| 146 | + STD %14, 24, $x1 :: (store 8 into stack + 24) |
| 147 | + %15:g8rc = EXTSW_32_64 %7 |
| 148 | + $x3 = COPY %15 |
| 149 | + $x12 = COPY %3 |
| 150 | + MTCTR8 %3, implicit-def $ctr8 |
| 151 | + BCTRL8_LDinto_toc 24, $x1, csr_svr464_altivec, implicit-def dead $lr8, implicit-def dead $x2, implicit $ctr8, implicit $rm, implicit $x3, implicit $x12, implicit $x2, implicit-def $r1 |
| 152 | + ADJCALLSTACKUP 32, 0, implicit-def dead $r1, implicit $r1 |
| 153 | +
|
| 154 | + bb.5.for.inc: |
| 155 | + successors: %bb.2(0x013521d0), %bb.3(0x7ecade30) |
| 156 | +
|
| 157 | + %2:gprc = nuw nsw ADDI %1, 1 |
| 158 | + %16:crrc = CMPLW %8, %2 |
| 159 | + BCC 76, killed %16, %bb.2 |
| 160 | + B %bb.3 |
| 161 | +
|
| 162 | +... |
| 163 | + |
| 164 | +# CHECK for enabling instruction hoisting |
| 165 | +#CHECK-LABEL: test |
| 166 | +#CHECK-HOIST: bb.1.for.body.lr.ph: |
| 167 | +#CHECK-HOIST: %14:g8rc = COPY $x2 |
| 168 | +#CHECK-HOIST: STD %14, 24, $x1 :: (store 8 into stack + 24) |
| 169 | +#CHECK-HOIST: %15:g8rc = EXTSW_32_64 %7 |
| 170 | +#CHECK-HOIST: B %bb.3 |
| 171 | + |
| 172 | +#CHECK-HOIST: bb.4.if.then: |
| 173 | +#CHECK-HOIST-NOT: %14:g8rc = COPY $x2 |
| 174 | +#CHECK-HOIST-NOT: STD %14, 24, $x1 :: (store 8 into stack + 24) |
| 175 | +#CHECK-HOIST-NOT: %15:g8rc = EXTSW_32_64 %7 |
| 176 | +#CHECK-HOIST: bb.5.for.inc: |
| 177 | + |
| 178 | +# CHECK for disabling instruction hoisting due to block hotness |
| 179 | +#CHECK-LABEL: test |
| 180 | +#CHECK-NO-HOIST: bb.1.for.body.lr.ph: |
| 181 | +#CHECK-NO-HOIST-NOT: %14:g8rc = COPY $x2 |
| 182 | +#CHECK-NO-HOIST-NOT: STD %14, 24, $x1 :: (store 8 into stack + 24) |
| 183 | +#CHECK-NO-HOIST-NOT: %15:g8rc = EXTSW_32_64 %7 |
| 184 | +#CHECK-NO-HOIST: B %bb.3 |
| 185 | + |
| 186 | +#CHECK-NO-HOIST: bb.4.if.then: |
| 187 | +#CHECK-NO-HOIST: %14:g8rc = COPY $x2 |
| 188 | +#CHECK-NO-HOIST: STD %14, 24, $x1 :: (store 8 into stack + 24) |
| 189 | +#CHECK-NO-HOIST: %15:g8rc = EXTSW_32_64 %7 |
| 190 | +#CHECK-NO-HOIST: bb.5.for.inc: |
0 commit comments