1; RUN: opt -S -licm < %s | FileCheck %s 2 3; CHECK: %arrayidx4.promoted = load i32, i32* %arrayidx4, align 1, !tbaa !{{[0-9]+$}} 4 5target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 6target triple = "x86_64-unknown-linux-gnu" 7 8@a = dso_local local_unnamed_addr global i16 0, align 2, !dbg !0 9@b = dso_local local_unnamed_addr global i16 0, align 2, !dbg !6 10 11define dso_local void @c(i32 %d) local_unnamed_addr #0 !dbg !13 { 12entry: 13 call void @llvm.dbg.value(metadata i32 undef, metadata !18, metadata !DIExpression()), !dbg !19 14 ret void, !dbg !20 15} 16 17declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 18 19define dso_local signext i16 @e(i32 %d) local_unnamed_addr #0 !dbg !21 { 20entry: 21 call void @llvm.dbg.value(metadata i32 %d, metadata !25, metadata !DIExpression()), !dbg !26 22 %conv = trunc i32 %d to i16, !dbg !27 23 ret i16 %conv, !dbg !28 24} 25 26define dso_local signext i16 @g() local_unnamed_addr #2 !dbg !29 { 27entry: 28 %l_284 = alloca [2 x [3 x [6 x i32]]], align 16 29 %0 = bitcast [2 x [3 x [6 x i32]]]* %l_284 to i8*, !dbg !39 30 call void @llvm.lifetime.start.p0i8(i64 144, i8* nonnull %0) #4, !dbg !39 31 call void @llvm.dbg.declare(metadata [2 x [3 x [6 x i32]]]* %l_284, metadata !33, metadata !DIExpression()), !dbg !40 32 %1 = load i16, i16* @a, align 2, !dbg !41, !tbaa !44 33 %cmp11 = icmp sgt i16 %1, -1, !dbg !48 34 br i1 %cmp11, label %for.body.lr.ph, label %cleanup, !dbg !49 35 36for.body.lr.ph: ; preds = %entry 37 br label %for.body, !dbg !49 38 39for.body: ; preds = %for.body.lr.ph, %for.cond2 40 %call = call signext i16 @e(i32 1), !dbg !50 41 %tobool = icmp eq i16 %call, 0, !dbg !50 42 br i1 %tobool, label %for.cond2, label %for.body.cleanup_crit_edge, !dbg !53 43 44for.cond2: ; preds = %for.body 45 %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 46 store i32 0, i32* %arrayidx4, align 4, !dbg !58, !tbaa !59 47 %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 48 %2 = load i32, i32* %arrayidx8, align 8, !dbg !61, !tbaa !59 49 %conv9 = trunc i32 %2 to i16, !dbg !61 50 store i16 %conv9, i16* @b, align 2, !dbg !62, !tbaa !44 51 %3 = load i16, i16* @a, align 2, !dbg !41, !tbaa !44 52 %cmp = icmp sgt i16 %3, -1, !dbg !48 53 br i1 %cmp, label %for.body, label %for.cond.cleanup_crit_edge, !dbg !49, !llvm.loop !63 54 55for.cond.cleanup_crit_edge: ; preds = %for.cond2 56 br label %cleanup, !dbg !49 57 58for.body.cleanup_crit_edge: ; preds = %for.body 59 br label %cleanup, !dbg !53 60 61cleanup: ; preds = %for.body.cleanup_crit_edge, %for.cond.cleanup_crit_edge, %entry 62 call void @llvm.lifetime.end.p0i8(i64 144, i8* nonnull %0) #4, !dbg !66 63 ret i16 1, !dbg !66 64} 65 66; Function Attrs: argmemonly nounwind willreturn 67declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #3 68 69; Function Attrs: norecurse nounwind readnone uwtable 70define internal signext i16 @f(i32 %d) #0 !dbg !67 { 71entry: 72 call void @llvm.dbg.value(metadata i32 %d, metadata !69, metadata !DIExpression()), !dbg !70 73 ret i16 undef, !dbg !71 74} 75 76; Function Attrs: argmemonly nounwind willreturn 77declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #3 78 79; Function Attrs: nounwind uwtable 80define dso_local i32 @main() local_unnamed_addr #2 !dbg !72 { 81entry: 82 %call = call signext i16 @g(), !dbg !75 83 ret i32 0, !dbg !76 84} 85 86declare void @llvm.dbg.value(metadata, metadata, metadata) 87 88attributes #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" } 89attributes #1 = { nounwind readnone speculatable willreturn } 90attributes #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" } 91attributes #3 = { argmemonly nounwind willreturn } 92attributes #4 = { nounwind } 93 94!llvm.dbg.cu = !{!2} 95!llvm.module.flags = !{!9, !10, !11} 96!llvm.ident = !{!12} 97 98!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 99!1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 1, type: !8, isLocal: false, isDefinition: true) 100!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 237d0e3c0416abf9919406bcc92874cfd15f5e0c)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None) 101!3 = !DIFile(filename: "a.c", directory: "/home/davide/lldb-build/bin") 102!4 = !{} 103!5 = !{!0, !6} 104!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) 105!7 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 1, type: !8, isLocal: false, isDefinition: true) 106!8 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed) 107!9 = !{i32 7, !"Dwarf Version", i32 4} 108!10 = !{i32 2, !"Debug Info Version", i32 3} 109!11 = !{i32 1, !"wchar_size", i32 4} 110!12 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 237d0e3c0416abf9919406bcc92874cfd15f5e0c)"} 111!13 = distinct !DISubprogram(name: "c", scope: !3, file: !3, line: 2, type: !14, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !17) 112!14 = !DISubroutineType(types: !15) 113!15 = !{null, !16} 114!16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 115!17 = !{!18} 116!18 = !DILocalVariable(name: "d", arg: 1, scope: !13, file: !3, line: 2, type: !16) 117!19 = !DILocation(line: 0, scope: !13) 118!20 = !DILocation(line: 2, column: 13, scope: !13) 119!21 = distinct !DISubprogram(name: "e", scope: !3, file: !3, line: 3, type: !22, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !24) 120!22 = !DISubroutineType(types: !23) 121!23 = !{!8, !16} 122!24 = !{!25} 123!25 = !DILocalVariable(name: "d", arg: 1, scope: !21, file: !3, line: 3, type: !16) 124!26 = !DILocation(line: 0, scope: !21) 125!27 = !DILocation(line: 3, column: 22, scope: !21) 126!28 = !DILocation(line: 3, column: 15, scope: !21) 127!29 = distinct !DISubprogram(name: "g", scope: !3, file: !3, line: 5, type: !30, scopeLine: 5, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !32) 128!30 = !DISubroutineType(types: !31) 129!31 = !{!8} 130!32 = !{!33} 131!33 = !DILocalVariable(name: "l_284", scope: !29, file: !3, line: 6, type: !34) 132!34 = !DICompositeType(tag: DW_TAG_array_type, baseType: !16, size: 1152, elements: !35) 133!35 = !{!36, !37, !38} 134!36 = !DISubrange(count: 2) 135!37 = !DISubrange(count: 3) 136!38 = !DISubrange(count: 6) 137!39 = !DILocation(line: 6, column: 3, scope: !29) 138!40 = !DILocation(line: 6, column: 7, scope: !29) 139!41 = !DILocation(line: 7, column: 10, scope: !42) 140!42 = distinct !DILexicalBlock(scope: !43, file: !3, line: 7, column: 3) 141!43 = distinct !DILexicalBlock(scope: !29, file: !3, line: 7, column: 3) 142!44 = !{!45, !45, i64 0} 143!45 = !{!"short", !46, i64 0} 144!46 = !{!"omnipotent char", !47, i64 0} 145!47 = !{!"Simple C/C++ TBAA"} 146!48 = !DILocation(line: 7, column: 12, scope: !42) 147!49 = !DILocation(line: 7, column: 3, scope: !43) 148!50 = !DILocation(line: 8, column: 9, scope: !51) 149!51 = distinct !DILexicalBlock(scope: !52, file: !3, line: 8, column: 9) 150!52 = distinct !DILexicalBlock(scope: !42, file: !3, line: 7, column: 19) 151!53 = !DILocation(line: 8, column: 9, scope: !52) 152!54 = !DILocation(line: 11, column: 7, scope: !55) 153!55 = distinct !DILexicalBlock(scope: !56, file: !3, line: 10, column: 14) 154!56 = distinct !DILexicalBlock(scope: !57, file: !3, line: 10, column: 5) 155!57 = distinct !DILexicalBlock(scope: !52, file: !3, line: 10, column: 5) 156!58 = !DILocation(line: 11, column: 22, scope: !55) 157!59 = !{!60, !60, i64 0} 158!60 = !{!"int", !46, i64 0} 159!61 = !DILocation(line: 16, column: 9, scope: !52) 160!62 = !DILocation(line: 16, column: 7, scope: !52) 161!63 = distinct !{!63, !49, !64, !65} 162!64 = !DILocation(line: 17, column: 3, scope: !43) 163!65 = !{!"llvm.loop.unroll.disable"} 164!66 = !DILocation(line: 18, column: 1, scope: !29) 165!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) 166!68 = !{!69} 167!69 = !DILocalVariable(name: "d", arg: 1, scope: !67, file: !3, line: 4, type: !16) 168!70 = !DILocation(line: 0, scope: !67) 169!71 = !DILocation(line: 4, column: 21, scope: !67) 170!72 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 19, type: !73, scopeLine: 19, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4) 171!73 = !DISubroutineType(types: !74) 172!74 = !{!16} 173!75 = !DILocation(line: 19, column: 14, scope: !72) 174!76 = !DILocation(line: 19, column: 19, scope: !72) 175