1 ; REQUIRES: aarch64-registered-target
2 ; RUN: opt -codegenprepare -mtriple=arm64-apple=ios -S -o - %s | FileCheck %s
4 @first_ones = external global [65536 x i8]
6 define i32 @fct19(i64 %arg1) #0 !dbg !6 {
9 %x.sroa.1.0.extract.shift = lshr i64 %arg1, 16, !dbg !35
10 %x.sroa.1.0.extract.trunc = trunc i64 %x.sroa.1.0.extract.shift to i16, !dbg !36
12 %x.sroa.3.0.extract.shift = lshr i64 %arg1, 32, !dbg !37
13 call void @llvm.dbg.value(metadata i64 %x.sroa.3.0.extract.shift, metadata !13, metadata !DIExpression()), !dbg !37
14 ; CHECK: call void @llvm.dbg.value(metadata i64 %arg1, metadata {{.*}}, metadata !DIExpression(DW_OP_constu, 32, DW_OP_shr, DW_OP_stack_value)), !dbg [[shift2_loc:![0-9]+]]
16 %x.sroa.5.0.extract.shift = lshr i64 %arg1, 48, !dbg !38
17 %tobool = icmp eq i64 %x.sroa.5.0.extract.shift, 0, !dbg !39
18 br i1 %tobool, label %if.end, label %if.then, !dbg !40
20 if.then: ; preds = %entry
21 %arrayidx3 = getelementptr inbounds [65536 x i8], [65536 x i8]* @first_ones, i64 0, i64 %x.sroa.5.0.extract.shift, !dbg !41
22 %0 = load i8, i8* %arrayidx3, align 1, !dbg !42
23 %conv = zext i8 %0 to i32, !dbg !43
24 br label %return, !dbg !44
26 if.end: ; preds = %entry
27 ; CHECK-LABEL: if.end:
28 ; CHECK-NEXT: lshr i64 %arg1, 32, !dbg [[shift2_loc]]
29 %x.sroa.3.0.extract.trunc = trunc i64 %x.sroa.3.0.extract.shift to i16, !dbg !45
30 %tobool6 = icmp eq i16 %x.sroa.3.0.extract.trunc, 0, !dbg !46
31 br i1 %tobool6, label %if.end13, label %if.then7, !dbg !47
33 if.then7: ; preds = %if.end
34 %idxprom10 = and i64 %x.sroa.3.0.extract.shift, 65535, !dbg !48
35 %arrayidx11 = getelementptr inbounds [65536 x i8], [65536 x i8]* @first_ones, i64 0, i64 %idxprom10, !dbg !49
36 %1 = load i8, i8* %arrayidx11, align 1, !dbg !50
37 %conv12 = zext i8 %1 to i32, !dbg !51
38 %add = add nsw i32 %conv12, 16, !dbg !52
39 br label %return, !dbg !53
41 if.end13: ; preds = %if.end
42 ; CHECK-LABEL: if.end13:
43 ; CHECK-NEXT: [[shift1:%.*]] = lshr i64 %arg1, 16, !dbg [[shift1_loc:![0-9]+]]
44 ; CHECK-NEXT: trunc i64 [[shift1]] to i16, !dbg [[trunc1_loc:![0-9]+]]
45 %tobool16 = icmp eq i16 %x.sroa.1.0.extract.trunc, 0, !dbg !54
46 br i1 %tobool16, label %return, label %if.then17, !dbg !55
48 if.then17: ; preds = %if.end13
49 %idxprom20 = and i64 %x.sroa.1.0.extract.shift, 65535, !dbg !56
50 %arrayidx21 = getelementptr inbounds [65536 x i8], [65536 x i8]* @first_ones, i64 0, i64 %idxprom20, !dbg !57
51 %2 = load i8, i8* %arrayidx21, align 1, !dbg !58
52 %conv22 = zext i8 %2 to i32, !dbg !59
53 %add23 = add nsw i32 %conv22, 32, !dbg !60
54 br label %return, !dbg !61
56 return: ; preds = %if.then17, %if.end13, %if.then7, %if.then
57 %retval.0 = phi i32 [ %conv, %if.then ], [ %add, %if.then7 ], [ %add23, %if.then17 ], [ 64, %if.end13 ], !dbg !62
58 ret i32 %retval.0, !dbg !63
61 ; CHECK: [[shift1_loc]] = !DILocation(line: 1
62 ; CHECK: [[trunc1_loc]] = !DILocation(line: 2
63 ; CHECK: [[shift2_loc]] = !DILocation(line: 3
65 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
67 attributes #0 = { nounwind readonly ssp }
68 attributes #1 = { nounwind readnone speculatable }
71 !llvm.module.flags = !{!5}
73 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
74 !1 = !DIFile(filename: "sink-shift-and-trunc.ll", directory: "/")
76 !5 = !{i32 2, !"Debug Info Version", i32 3}
77 !6 = distinct !DISubprogram(name: "fct19", linkageName: "fct19", scope: null, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0, retainedNodes: !8)
78 !7 = !DISubroutineType(types: !2)
80 !10 = !DIBasicType(name: "ty64", size: 64, encoding: DW_ATE_unsigned)
81 !13 = !DILocalVariable(name: "3", scope: !6, file: !1, line: 3, type: !10)
82 !35 = !DILocation(line: 1, column: 1, scope: !6)
83 !36 = !DILocation(line: 2, column: 1, scope: !6)
84 !37 = !DILocation(line: 3, column: 1, scope: !6)
85 !38 = !DILocation(line: 4, column: 1, scope: !6)
86 !39 = !DILocation(line: 5, column: 1, scope: !6)
87 !40 = !DILocation(line: 6, column: 1, scope: !6)
88 !41 = !DILocation(line: 7, column: 1, scope: !6)
89 !42 = !DILocation(line: 8, column: 1, scope: !6)
90 !43 = !DILocation(line: 9, column: 1, scope: !6)
91 !44 = !DILocation(line: 10, column: 1, scope: !6)
92 !45 = !DILocation(line: 11, column: 1, scope: !6)
93 !46 = !DILocation(line: 12, column: 1, scope: !6)
94 !47 = !DILocation(line: 13, column: 1, scope: !6)
95 !48 = !DILocation(line: 14, column: 1, scope: !6)
96 !49 = !DILocation(line: 15, column: 1, scope: !6)
97 !50 = !DILocation(line: 16, column: 1, scope: !6)
98 !51 = !DILocation(line: 17, column: 1, scope: !6)
99 !52 = !DILocation(line: 18, column: 1, scope: !6)
100 !53 = !DILocation(line: 19, column: 1, scope: !6)
101 !54 = !DILocation(line: 20, column: 1, scope: !6)
102 !55 = !DILocation(line: 21, column: 1, scope: !6)
103 !56 = !DILocation(line: 22, column: 1, scope: !6)
104 !57 = !DILocation(line: 23, column: 1, scope: !6)
105 !58 = !DILocation(line: 24, column: 1, scope: !6)
106 !59 = !DILocation(line: 25, column: 1, scope: !6)
107 !60 = !DILocation(line: 26, column: 1, scope: !6)
108 !61 = !DILocation(line: 27, column: 1, scope: !6)
109 !62 = !DILocation(line: 28, column: 1, scope: !6)
110 !63 = !DILocation(line: 29, column: 1, scope: !6)