[llvm] 9a63978 - [LICM] Trim unneeded functions from test, add promote-able load.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 10 13:26:14 PDT 2022


Author: Florian Hahn
Date: 2022-04-10T22:25:05+02:00
New Revision: 9a63978b854b5838a7434e5302f05cc8a785fe94

URL: https://github.com/llvm/llvm-project/commit/9a63978b854b5838a7434e5302f05cc8a785fe94
DIFF: https://github.com/llvm/llvm-project/commit/9a63978b854b5838a7434e5302f05cc8a785fe94.diff

LOG: [LICM] Trim unneeded functions from test, add promote-able load.

Clean up the test a bit. Also add a promote-able load, to make sure LICM
always has to hoist the load.

Added: 
    

Modified: 
    llvm/test/Transforms/LICM/hoisting-preheader-debugloc.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/LICM/hoisting-preheader-debugloc.ll b/llvm/test/Transforms/LICM/hoisting-preheader-debugloc.ll
index 381d9c77ecd8b..67abe66a7d6aa 100644
--- a/llvm/test/Transforms/LICM/hoisting-preheader-debugloc.ll
+++ b/llvm/test/Transforms/LICM/hoisting-preheader-debugloc.ll
@@ -1,95 +1,70 @@
-; RUN: opt -S -licm < %s | FileCheck %s
+; RUN: opt -passes=licm %s -S | FileCheck %s
 
-; CHECK: %arrayidx4.promoted = load i32, i32* %arrayidx4, align 1, !tbaa !{{[0-9]+$}}
+; CHECK: %arrayidx4.promoted = load i32, i32* %arrayidx4, align 4, !tbaa !{{[0-9]+$}}
 
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
 
 @a = dso_local local_unnamed_addr global i16 0, align 2, !dbg !0
 @b = dso_local local_unnamed_addr global i16 0, align 2, !dbg !6
 
-define dso_local void @c(i32 %d) local_unnamed_addr #0 !dbg !13 {
-entry:
-  call void @llvm.dbg.value(metadata i32 undef, metadata !18, metadata !DIExpression()), !dbg !19
-  ret void, !dbg !20
-}
-
-declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
 
-define dso_local signext i16 @e(i32 %d) local_unnamed_addr #0 !dbg !21 {
-entry:
-  call void @llvm.dbg.value(metadata i32 %d, metadata !25, metadata !DIExpression()), !dbg !26
-  %conv = trunc i32 %d to i16, !dbg !27
-  ret i16 %conv, !dbg !28
-}
+declare i16 @e(i32)
 
-define dso_local signext i16 @g() local_unnamed_addr #2 !dbg !29 {
+define i16 @g() !dbg !13 {
 entry:
   %l_284 = alloca [2 x [3 x [6 x i32]]], align 16
-  %0 = bitcast [2 x [3 x [6 x i32]]]* %l_284 to i8*, !dbg !39
-  call void @llvm.lifetime.start.p0i8(i64 144, i8* nonnull %0) #4, !dbg !39
-  call void @llvm.dbg.declare(metadata [2 x [3 x [6 x i32]]]* %l_284, metadata !33, metadata !DIExpression()), !dbg !40
-  %1 = load i16, i16* @a, align 2, !dbg !41, !tbaa !44
-  %cmp11 = icmp sgt i16 %1, -1, !dbg !48
-  br i1 %cmp11, label %for.body.lr.ph, label %cleanup, !dbg !49
+  %0 = bitcast [2 x [3 x [6 x i32]]]* %l_284 to i8*, !dbg !24
+  call void @llvm.lifetime.start.p0i8(i64 144, i8* nonnull %0), !dbg !24
+  call void @llvm.dbg.declare(metadata [2 x [3 x [6 x i32]]]* %l_284, metadata !17, metadata !DIExpression()), !dbg !25
+  %1 = load i16, i16* @a, align 2, !dbg !26, !tbaa !29
+  %cmp11 = icmp sgt i16 %1, -1, !dbg !33
+  br i1 %cmp11, label %for.body.lr.ph, label %cleanup, !dbg !34
 
 for.body.lr.ph:                                   ; preds = %entry
-  br label %for.body, !dbg !49
+  br label %for.body, !dbg !34
 
-for.body:                                         ; preds = %for.body.lr.ph, %for.cond2
-  %call = call signext i16 @e(i32 1), !dbg !50
-  %tobool = icmp eq i16 %call, 0, !dbg !50
-  br i1 %tobool, label %for.cond2, label %for.body.cleanup_crit_edge, !dbg !53
+for.body:                                         ; preds = %for.cond2, %for.body.lr.ph
+  %call = call signext i16 @e(i32 1), !dbg !35
+  %tobool = icmp eq i16 %call, 0, !dbg !35
+  br i1 %tobool, label %for.cond2, label %for.body.cleanup_crit_edge, !dbg !38
 
 for.cond2:                                        ; preds = %for.body
-  %arrayidx4 = getelementptr inbounds [2 x [3 x [6 x i32]]], [2 x [3 x [6 x i32]]]* %l_284, i64 0, i64 1, i64 2, i64 5, !dbg !54
-  store i32 0, i32* %arrayidx4, align 4, !dbg !58, !tbaa !59
-  %arrayidx8 = getelementptr inbounds [2 x [3 x [6 x i32]]], [2 x [3 x [6 x i32]]]* %l_284, i64 0, i64 1, i64 1, i64 4, !dbg !61
-  %2 = load i32, i32* %arrayidx8, align 8, !dbg !61, !tbaa !59
-  %conv9 = trunc i32 %2 to i16, !dbg !61
-  store i16 %conv9, i16* @b, align 2, !dbg !62, !tbaa !44
-  %3 = load i16, i16* @a, align 2, !dbg !41, !tbaa !44
-  %cmp = icmp sgt i16 %3, -1, !dbg !48
-  br i1 %cmp, label %for.body, label %for.cond.cleanup_crit_edge, !dbg !49, !llvm.loop !63
+  %arrayidx4 = getelementptr inbounds [2 x [3 x [6 x i32]]], [2 x [3 x [6 x i32]]]* %l_284, i64 0, i64 1, i64 2, i64 5, !dbg !39
+  %l = load i32, i32* %arrayidx4, !dbg !43, !tbaa !44
+  %add = add i32 %l, 1, !dbg !43
+  store i32 %add, i32* %arrayidx4, align 4, !dbg !43, !tbaa !44
+  %arrayidx8 = getelementptr inbounds [2 x [3 x [6 x i32]]], [2 x [3 x [6 x i32]]]* %l_284, i64 0, i64 1, i64 1, i64 4, !dbg !46
+  %2 = load i32, i32* %arrayidx8, align 8, !dbg !46, !tbaa !44
+  %conv9 = trunc i32 %2 to i16, !dbg !46
+  store i16 %conv9, i16* @b, align 2, !dbg !47, !tbaa !29
+  %3 = load i16, i16* @a, align 2, !dbg !26, !tbaa !29
+  %cmp = icmp sgt i16 %3, -1, !dbg !33
+  br i1 %cmp, label %for.body, label %for.cond.cleanup_crit_edge, !dbg !34, !llvm.loop !48
 
 for.cond.cleanup_crit_edge:                       ; preds = %for.cond2
-  br label %cleanup, !dbg !49
+  br label %cleanup, !dbg !34
 
 for.body.cleanup_crit_edge:                       ; preds = %for.body
-  br label %cleanup, !dbg !53
+  br label %cleanup, !dbg !38
 
 cleanup:                                          ; preds = %for.body.cleanup_crit_edge, %for.cond.cleanup_crit_edge, %entry
-  call void @llvm.lifetime.end.p0i8(i64 144, i8* nonnull %0) #4, !dbg !66
-  ret i16 1, !dbg !66
+  call void @llvm.lifetime.end.p0i8(i64 144, i8* nonnull %0), !dbg !51
+  ret i16 1, !dbg !51
 }
 
-; Function Attrs: argmemonly nounwind willreturn
-declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #3
+; Function Attrs: argmemonly nocallback nofree nosync nounwind willreturn
+declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
 
-; Function Attrs: norecurse nounwind readnone uwtable
-define internal signext i16 @f(i32 %d) #0 !dbg !67 {
-entry:
-  call void @llvm.dbg.value(metadata i32 %d, metadata !69, metadata !DIExpression()), !dbg !70
-  ret i16 undef, !dbg !71
-}
-
-; Function Attrs: argmemonly nounwind willreturn
-declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #3
-
-; Function Attrs: nounwind uwtable
-define dso_local i32 @main() local_unnamed_addr #2 !dbg !72 {
-entry:
-  %call = call signext i16 @g(), !dbg !75
-  ret i32 0, !dbg !76
-}
+; Function Attrs: argmemonly nocallback nofree nosync nounwind willreturn
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
 
-declare void @llvm.dbg.value(metadata, metadata, metadata)
+; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #0
 
-attributes #0 = { norecurse nounwind readnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
-attributes #1 = { nounwind readnone speculatable willreturn }
-attributes #2 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
-attributes #3 = { argmemonly nounwind willreturn }
-attributes #4 = { nounwind }
+attributes #0 = { nocallback nofree nosync nounwind readnone speculatable willreturn }
+attributes #1 = { argmemonly nocallback nofree nosync nounwind willreturn }
 
 !llvm.dbg.cu = !{!2}
 !llvm.module.flags = !{!9, !10, !11}
@@ -108,67 +83,42 @@ attributes #4 = { nounwind }
 !10 = !{i32 2, !"Debug Info Version", i32 3}
 !11 = !{i32 1, !"wchar_size", i32 4}
 !12 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 237d0e3c0416abf9919406bcc92874cfd15f5e0c)"}
-!13 = distinct !DISubprogram(name: "c", scope: !3, file: !3, line: 2, type: !14, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !17)
+!13 = distinct !DISubprogram(name: "g", scope: !3, file: !3, line: 5, type: !14, scopeLine: 5, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !16)
 !14 = !DISubroutineType(types: !15)
-!15 = !{null, !16}
-!16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!17 = !{!18}
-!18 = !DILocalVariable(name: "d", arg: 1, scope: !13, file: !3, line: 2, type: !16)
-!19 = !DILocation(line: 0, scope: !13)
-!20 = !DILocation(line: 2, column: 13, scope: !13)
-!21 = distinct !DISubprogram(name: "e", scope: !3, file: !3, line: 3, type: !22, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !24)
-!22 = !DISubroutineType(types: !23)
-!23 = !{!8, !16}
-!24 = !{!25}
-!25 = !DILocalVariable(name: "d", arg: 1, scope: !21, file: !3, line: 3, type: !16)
-!26 = !DILocation(line: 0, scope: !21)
-!27 = !DILocation(line: 3, column: 22, scope: !21)
-!28 = !DILocation(line: 3, column: 15, scope: !21)
-!29 = distinct !DISubprogram(name: "g", scope: !3, file: !3, line: 5, type: !30, scopeLine: 5, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !32)
-!30 = !DISubroutineType(types: !31)
-!31 = !{!8}
-!32 = !{!33}
-!33 = !DILocalVariable(name: "l_284", scope: !29, file: !3, line: 6, type: !34)
-!34 = !DICompositeType(tag: DW_TAG_array_type, baseType: !16, size: 1152, elements: !35)
-!35 = !{!36, !37, !38}
-!36 = !DISubrange(count: 2)
-!37 = !DISubrange(count: 3)
-!38 = !DISubrange(count: 6)
-!39 = !DILocation(line: 6, column: 3, scope: !29)
-!40 = !DILocation(line: 6, column: 7, scope: !29)
-!41 = !DILocation(line: 7, column: 10, scope: !42)
-!42 = distinct !DILexicalBlock(scope: !43, file: !3, line: 7, column: 3)
-!43 = distinct !DILexicalBlock(scope: !29, file: !3, line: 7, column: 3)
+!15 = !{!8}
+!16 = !{!17}
+!17 = !DILocalVariable(name: "l_284", scope: !13, file: !3, line: 6, type: !18)
+!18 = !DICompositeType(tag: DW_TAG_array_type, baseType: !19, size: 1152, elements: !20)
+!19 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!20 = !{!21, !22, !23}
+!21 = !DISubrange(count: 2)
+!22 = !DISubrange(count: 3)
+!23 = !DISubrange(count: 6)
+!24 = !DILocation(line: 6, column: 3, scope: !13)
+!25 = !DILocation(line: 6, column: 7, scope: !13)
+!26 = !DILocation(line: 7, column: 10, scope: !27)
+!27 = distinct !DILexicalBlock(scope: !28, file: !3, line: 7, column: 3)
+!28 = distinct !DILexicalBlock(scope: !13, file: !3, line: 7, column: 3)
+!29 = !{!30, !30, i64 0}
+!30 = !{!"short", !31, i64 0}
+!31 = !{!"omnipotent char", !32, i64 0}
+!32 = !{!"Simple C/C++ TBAA"}
+!33 = !DILocation(line: 7, column: 12, scope: !27)
+!34 = !DILocation(line: 7, column: 3, scope: !28)
+!35 = !DILocation(line: 8, column: 9, scope: !36)
+!36 = distinct !DILexicalBlock(scope: !37, file: !3, line: 8, column: 9)
+!37 = distinct !DILexicalBlock(scope: !27, file: !3, line: 7, column: 19)
+!38 = !DILocation(line: 8, column: 9, scope: !37)
+!39 = !DILocation(line: 11, column: 7, scope: !40)
+!40 = distinct !DILexicalBlock(scope: !41, file: !3, line: 10, column: 14)
+!41 = distinct !DILexicalBlock(scope: !42, file: !3, line: 10, column: 5)
+!42 = distinct !DILexicalBlock(scope: !37, file: !3, line: 10, column: 5)
+!43 = !DILocation(line: 11, column: 22, scope: !40)
 !44 = !{!45, !45, i64 0}
-!45 = !{!"short", !46, i64 0}
-!46 = !{!"omnipotent char", !47, i64 0}
-!47 = !{!"Simple C/C++ TBAA"}
-!48 = !DILocation(line: 7, column: 12, scope: !42)
-!49 = !DILocation(line: 7, column: 3, scope: !43)
-!50 = !DILocation(line: 8, column: 9, scope: !51)
-!51 = distinct !DILexicalBlock(scope: !52, file: !3, line: 8, column: 9)
-!52 = distinct !DILexicalBlock(scope: !42, file: !3, line: 7, column: 19)
-!53 = !DILocation(line: 8, column: 9, scope: !52)
-!54 = !DILocation(line: 11, column: 7, scope: !55)
-!55 = distinct !DILexicalBlock(scope: !56, file: !3, line: 10, column: 14)
-!56 = distinct !DILexicalBlock(scope: !57, file: !3, line: 10, column: 5)
-!57 = distinct !DILexicalBlock(scope: !52, file: !3, line: 10, column: 5)
-!58 = !DILocation(line: 11, column: 22, scope: !55)
-!59 = !{!60, !60, i64 0}
-!60 = !{!"int", !46, i64 0}
-!61 = !DILocation(line: 16, column: 9, scope: !52)
-!62 = !DILocation(line: 16, column: 7, scope: !52)
-!63 = distinct !{!63, !49, !64, !65}
-!64 = !DILocation(line: 17, column: 3, scope: !43)
-!65 = !{!"llvm.loop.unroll.disable"}
-!66 = !DILocation(line: 18, column: 1, scope: !29)
-!67 = distinct !DISubprogram(name: "f", scope: !3, file: !3, line: 4, type: !22, scopeLine: 4, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !68)
-!68 = !{!69}
-!69 = !DILocalVariable(name: "d", arg: 1, scope: !67, file: !3, line: 4, type: !16)
-!70 = !DILocation(line: 0, scope: !67)
-!71 = !DILocation(line: 4, column: 21, scope: !67)
-!72 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 19, type: !73, scopeLine: 19, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
-!73 = !DISubroutineType(types: !74)
-!74 = !{!16}
-!75 = !DILocation(line: 19, column: 14, scope: !72)
-!76 = !DILocation(line: 19, column: 19, scope: !72)
+!45 = !{!"int", !31, i64 0}
+!46 = !DILocation(line: 16, column: 9, scope: !37)
+!47 = !DILocation(line: 16, column: 7, scope: !37)
+!48 = distinct !{!48, !34, !49, !50}
+!49 = !DILocation(line: 17, column: 3, scope: !28)
+!50 = !{!"llvm.loop.unroll.disable"}
+!51 = !DILocation(line: 18, column: 1, scope: !13)


        


More information about the llvm-commits mailing list