328 lines · plain
1# RUN: llc -mtriple=hexagon -run-pass machine-sink -o - %s | FileCheck %s2 3# RUN: llc -march=hexagon -passes machine-sink -o - %s | FileCheck %s4 5# Test that MachineSink does not sink F2_conv_w2sf.6# CHECK: name:{{.*}} main7# CHECK: J2_call @feclearexcept8# CHECK: F2_conv_w2sf9# CHECK: J2_call @fetestexcept10--- |11 target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"12 target triple = "hexagon"13 14 @.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 115 16 ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn17 define dso_local i32 @syst_int32_to_float32(i32 %a) local_unnamed_addr #0 {18 entry:19 %conv = sitofp i32 %a to float20 %0 = bitcast float %conv to i3221 ret i32 %022 }23 24 ; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn25 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #126 27 ; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn28 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #129 30 ; Function Attrs: nounwind31 define dso_local i32 @main() local_unnamed_addr #2 {32 entry:33 %a = alloca i32, align 434 %b = alloca i32, align 435 %c = alloca i32, align 436 %a.0.a.0.a.0.a.0..sroa_cast = bitcast ptr %a to ptr37 call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a.0.a.0.a.0.a.0..sroa_cast)38 store volatile i32 -16777235, ptr %a, align 4, !tbaa !339 %b.0.b.0.b.0.b.0..sroa_cast = bitcast ptr %b to ptr40 call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b.0.b.0.b.0.b.0..sroa_cast)41 store volatile i32 34, ptr %b, align 4, !tbaa !342 %c.0.c.0.c.0.c.0..sroa_cast = bitcast ptr %c to ptr43 call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c.0.c.0.c.0.c.0..sroa_cast)44 store volatile i32 34, ptr %c, align 4, !tbaa !345 %b.0.b.0.b.0.b.0.29 = load volatile i32, ptr %b, align 4, !tbaa !346 %cmp30 = icmp sgt i32 %b.0.b.0.b.0.b.0.29, 047 br i1 %cmp30, label %for.body, label %if.end48 49 for.cond.for.cond.cleanup_crit_edge: ; preds = %for.body50 %conv.i.le = sitofp i32 %a.0.a.0.a.0.a.0. to float51 %0 = bitcast float %conv.i.le to i3252 %phi.cmp = icmp ugt i32 %0, 10053 br i1 %phi.cmp, label %if.then, label %if.end54 55 for.body: ; preds = %entry, %for.body56 %i.031 = phi i32 [ %inc4, %for.body ], [ 0, %entry ]57 %c.0.c.0.c.0.c.0. = load volatile i32, ptr %c, align 4, !tbaa !358 %inc = add nsw i32 %c.0.c.0.c.0.c.0., 159 store volatile i32 %inc, ptr %c, align 4, !tbaa !360 %call = tail call i32 @feclearexcept(i32 31) #561 %a.0.a.0.a.0.a.0. = load volatile i32, ptr %a, align 4, !tbaa !362 %call2 = tail call i32 @fetestexcept(i32 31) #563 %call3 = tail call i32 (ptr, ...) @printf(ptr nonnull dereferenceable(1) @.str, i32 %call2) #564 %inc4 = add nuw nsw i32 %i.031, 165 %b.0.b.0.b.0.b.0. = load volatile i32, ptr %b, align 4, !tbaa !366 %cmp = icmp slt i32 %inc4, %b.0.b.0.b.0.b.0.67 br i1 %cmp, label %for.body, label %for.cond.for.cond.cleanup_crit_edge, !llvm.loop !768 69 if.then: ; preds = %for.cond.for.cond.cleanup_crit_edge70 %a.0.a.0.a.0.a.0.23 = load volatile i32, ptr %a, align 4, !tbaa !371 %b.0.b.0.b.0.b.0.20 = load volatile i32, ptr %b, align 4, !tbaa !372 %add = add nsw i32 %b.0.b.0.b.0.b.0.20, %a.0.a.0.a.0.a.0.2373 %c.0.c.0.c.0.c.0.17 = load volatile i32, ptr %c, align 4, !tbaa !374 %add7 = add nsw i32 %add, %c.0.c.0.c.0.c.0.1775 br label %cleanup76 77 if.end: ; preds = %entry, %for.cond.for.cond.cleanup_crit_edge78 %a.0.a.0.a.0.a.0.24 = load volatile i32, ptr %a, align 4, !tbaa !379 %b.0.b.0.b.0.b.0.21 = load volatile i32, ptr %b, align 4, !tbaa !380 %mul.neg = mul i32 %b.0.b.0.b.0.b.0.21, -681 %sub = add i32 %mul.neg, %a.0.a.0.a.0.a.0.2482 %c.0.c.0.c.0.c.0.18 = load volatile i32, ptr %c, align 4, !tbaa !383 %mul8 = mul nsw i32 %c.0.c.0.c.0.c.0.18, 384 %add9 = add nsw i32 %sub, %mul885 br label %cleanup86 87 cleanup: ; preds = %if.end, %if.then88 %retval.0 = phi i32 [ %add7, %if.then ], [ %add9, %if.end ]89 %1 = bitcast ptr %c to ptr90 %2 = bitcast ptr %b to ptr91 %3 = bitcast ptr %a to ptr92 call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1)93 call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2)94 call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3)95 ret i32 %retval.096 }97 98 declare dso_local i32 @feclearexcept(i32) local_unnamed_addr #399 100 declare dso_local i32 @fetestexcept(i32) local_unnamed_addr #3101 102 ; Function Attrs: nofree nounwind103 declare dso_local noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4104 105 attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone willreturn "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="hexagonv68" "target-features"="+v68,-long-calls" }106 attributes #1 = { argmemonly mustprogress nofree nosync nounwind willreturn }107 attributes #2 = { nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="hexagonv68" "target-features"="+v68,-long-calls" }108 attributes #3 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="hexagonv68" "target-features"="+v68,-long-calls" }109 attributes #4 = { nofree nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="hexagonv68" "target-features"="+v68,-long-calls" }110 attributes #5 = { nounwind }111 112 !llvm.module.flags = !{!0, !1}113 114 !0 = !{i32 1, !"wchar_size", i32 4}115 !1 = !{i32 7, !"frame-pointer", i32 2}116 !3 = !{!4, !4, i64 0}117 !4 = !{!"int", !5, i64 0}118 !5 = !{!"omnipotent char", !6, i64 0}119 !6 = !{!"Simple C/C++ TBAA"}120 !7 = distinct !{!7, !8}121 !8 = !{!"llvm.loop.mustprogress"}122 123...124---125name: syst_int32_to_float32126alignment: 16127exposesReturnsTwice: false128legalized: false129regBankSelected: false130selected: false131failedISel: false132tracksRegLiveness: true133hasWinCFI: false134registers:135 - { id: 0, class: intregs, preferred-register: '' }136 - { id: 1, class: intregs, preferred-register: '' }137liveins:138 - { reg: '$r0', virtual-reg: '%0' }139frameInfo:140 isFrameAddressTaken: false141 isReturnAddressTaken: false142 hasStackMap: false143 hasPatchPoint: false144 stackSize: 0145 offsetAdjustment: 0146 maxAlignment: 1147 adjustsStack: false148 hasCalls: false149 stackProtector: ''150 maxCallFrameSize: 4294967295151 cvBytesOfCalleeSavedRegisters: 0152 hasOpaqueSPAdjustment: false153 hasVAStart: false154 hasMustTailInVarArgFunc: false155 hasTailCall: false156 localFrameSize: 0157 savePoint: []158 restorePoint: []159fixedStack: []160stack: []161callSites: []162debugValueSubstitutions: []163constants: []164machineFunctionInfo: {}165body: |166 bb.0.entry:167 liveins: $r0168 169 %0:intregs = COPY $r0170 %1:intregs = F2_conv_w2sf %0, implicit $usr171 $r0 = COPY %1172 PS_jmpret $r31, implicit-def dead $pc, implicit $r0173 174...175---176name: main177alignment: 16178exposesReturnsTwice: false179legalized: false180regBankSelected: false181selected: false182failedISel: false183tracksRegLiveness: true184hasWinCFI: false185registers:186 - { id: 0, class: intregs, preferred-register: '' }187 - { id: 1, class: intregs, preferred-register: '' }188 - { id: 2, class: intregs, preferred-register: '' }189 - { id: 3, class: intregs, preferred-register: '' }190 - { id: 4, class: intregs, preferred-register: '' }191 - { id: 5, class: intregs, preferred-register: '' }192 - { id: 6, class: intregs, preferred-register: '' }193 - { id: 7, class: intregs, preferred-register: '' }194 - { id: 8, class: predregs, preferred-register: '' }195 - { id: 9, class: intregs, preferred-register: '' }196 - { id: 10, class: intregs, preferred-register: '' }197 - { id: 11, class: intregs, preferred-register: '' }198 - { id: 12, class: intregs, preferred-register: '' }199 - { id: 13, class: intregs, preferred-register: '' }200 - { id: 14, class: intregs, preferred-register: '' }201 - { id: 15, class: intregs, preferred-register: '' }202 - { id: 16, class: predregs, preferred-register: '' }203 - { id: 17, class: intregs, preferred-register: '' }204 - { id: 18, class: predregs, preferred-register: '' }205 - { id: 19, class: intregs, preferred-register: '' }206 - { id: 20, class: intregs, preferred-register: '' }207 - { id: 21, class: intregs, preferred-register: '' }208 - { id: 22, class: intregs, preferred-register: '' }209 - { id: 23, class: intregs, preferred-register: '' }210 - { id: 24, class: intregs, preferred-register: '' }211 - { id: 25, class: intregs, preferred-register: '' }212 - { id: 26, class: intregs, preferred-register: '' }213 - { id: 27, class: intregs, preferred-register: '' }214liveins: []215frameInfo:216 isFrameAddressTaken: false217 isReturnAddressTaken: false218 hasStackMap: false219 hasPatchPoint: false220 stackSize: 0221 offsetAdjustment: 0222 maxAlignment: 4223 adjustsStack: false224 hasCalls: true225 stackProtector: ''226 maxCallFrameSize: 4294967295227 cvBytesOfCalleeSavedRegisters: 0228 hasOpaqueSPAdjustment: false229 hasVAStart: false230 hasMustTailInVarArgFunc: false231 hasTailCall: false232 localFrameSize: 0233 savePoint: []234 restorePoint: []235fixedStack: []236stack:237 - { id: 0, name: a, type: default, offset: 0, size: 4, alignment: 4,238 stack-id: default, callee-saved-register: '', callee-saved-restored: true,239 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }240 - { id: 1, name: b, type: default, offset: 0, size: 4, alignment: 4,241 stack-id: default, callee-saved-register: '', callee-saved-restored: true,242 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }243 - { id: 2, name: c, type: default, offset: 0, size: 4, alignment: 4,244 stack-id: default, callee-saved-register: '', callee-saved-restored: true,245 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }246callSites: []247debugValueSubstitutions: []248constants: []249machineFunctionInfo: {}250body: |251 bb.0.entry:252 successors: %bb.6(0x50000000), %bb.4(0x30000000)253 254 S4_storeiri_io %stack.0.a, 0, -16777235 :: (volatile store (s32) into %ir.a, !tbaa !3)255 S4_storeiri_io %stack.1.b, 0, 34 :: (volatile store (s32) into %ir.b, !tbaa !3)256 S4_storeiri_io %stack.2.c, 0, 34 :: (volatile store (s32) into %ir.c, !tbaa !3)257 %7:intregs = L2_loadri_io %stack.1.b, 0 :: (volatile dereferenceable load (s32) from %ir.b, !tbaa !3)258 %8:predregs = C2_cmpgti %7, 0259 %6:intregs = A2_tfrsi 0260 J2_jumpf %8, %bb.4, implicit-def $pc261 262 bb.6:263 successors: %bb.2(0x80000000)264 265 %9:intregs = A2_tfrsi 31266 %13:intregs = A2_tfrsi @.str267 J2_jump %bb.2, implicit-def $pc268 269 bb.1.for.cond.for.cond.cleanup_crit_edge:270 successors: %bb.4(0x40000000)271 272 J2_jump %bb.4, implicit-def dead $pc273 274 bb.2.for.body:275 successors: %bb.2(0x7c000000), %bb.1(0x04000000)276 277 %0:intregs = PHI %6, %bb.6, %2, %bb.2278 L4_iadd_memopw_io %stack.2.c, 0, 1 :: (volatile store (s32) into %ir.c, !tbaa !3), (volatile dereferenceable load (s32) from %ir.c, !tbaa !3)279 ADJCALLSTACKDOWN 0, 0, implicit-def $r29, implicit-def dead $r30, implicit $r31, implicit $r30, implicit $r29280 $r0 = COPY %9281 J2_call @feclearexcept, hexagoncsr, implicit-def dead $pc, implicit-def dead $r31, implicit $r29, implicit $r0, implicit-def $r29, implicit-def $r0282 ADJCALLSTACKUP 0, 0, implicit-def dead $r29, implicit-def dead $r30, implicit-def dead $r31, implicit $r29283 %1:intregs = L2_loadri_io %stack.0.a, 0 :: (volatile dereferenceable load (s32) from %ir.a, !tbaa !3)284 ADJCALLSTACKDOWN 0, 0, implicit-def $r29, implicit-def dead $r30, implicit $r31, implicit $r30, implicit $r29285 %17:intregs = F2_conv_w2sf %1, implicit $usr286 $r0 = COPY %9287 J2_call @fetestexcept, hexagoncsr, implicit-def dead $pc, implicit-def dead $r31, implicit $r29, implicit $r0, implicit-def $r29, implicit-def $r0288 ADJCALLSTACKUP 0, 0, implicit-def dead $r29, implicit-def dead $r30, implicit-def dead $r31, implicit $r29289 %11:intregs = COPY $r0290 %12:intregs = COPY $r29291 S2_storeri_io %12, 0, %11 :: (store (s32) into stack)292 ADJCALLSTACKDOWN 4, 0, implicit-def $r29, implicit-def dead $r30, implicit $r31, implicit $r30, implicit $r29293 $r0 = COPY %13294 J2_call @printf, hexagoncsr, implicit-def dead $pc, implicit-def dead $r31, implicit $r29, implicit $r0, implicit-def $r29, implicit-def $r0295 ADJCALLSTACKUP 4, 0, implicit-def dead $r29, implicit-def dead $r30, implicit-def dead $r31, implicit $r29296 %2:intregs = nuw nsw A2_addi %0, 1297 %15:intregs = L2_loadri_io %stack.1.b, 0 :: (volatile dereferenceable load (s32) from %ir.b, !tbaa !3)298 %16:predregs = C2_cmpgt %15, %2299 J2_jumpt %16, %bb.2, implicit-def dead $pc300 J2_jump %bb.1, implicit-def dead $pc301 302 bb.3.if.then:303 successors: %bb.5(0x80000000)304 305 %18:predregs = C2_cmpgtui %17, 100306 %24:intregs = L2_loadri_io %stack.0.a, 0 :: (volatile dereferenceable load (s32) from %ir.a, !tbaa !3)307 %25:intregs = L2_loadri_io %stack.1.b, 0 :: (volatile dereferenceable load (s32) from %ir.b, !tbaa !3)308 %26:intregs = L2_loadri_io %stack.2.c, 0 :: (volatile dereferenceable load (s32) from %ir.c, !tbaa !3)309 %3:intregs = nsw M2_acci %26, %25, %24310 J2_jumpf %18, %bb.5, implicit-def dead $pc311 J2_jump %bb.5, implicit-def dead $pc312 313 bb.4.if.end:314 successors: %bb.5(0x80000000)315 316 %19:intregs = L2_loadri_io %stack.0.a, 0 :: (volatile dereferenceable load (s32) from %ir.a, !tbaa !3)317 %20:intregs = L2_loadri_io %stack.1.b, 0 :: (volatile dereferenceable load (s32) from %ir.b, !tbaa !3)318 %27:intregs = M2_macsin %19, %20, 6319 %23:intregs = L2_loadri_io %stack.2.c, 0 :: (volatile dereferenceable load (s32) from %ir.c, !tbaa !3)320 %4:intregs = nsw M2_macsip %27, %23, 3321 322 bb.5.cleanup:323 %5:intregs = PHI %4, %bb.4, %3, %bb.3324 $r0 = COPY %5325 PS_jmpret $r31, implicit-def dead $pc, implicit $r0326 327...328