| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6 | |
| ; RUN: opt -S -passes=instcombine %s | FileCheck %s | |
| ;; InstCombine replaces the extract->insert pair with a pair of shufflevector | |
| ;; instructions, which first widen the %load vector and then replace the | |
| ;; extract->insert with a shufflevector of the widened vector and the insert | |
| ;; vector. | |
| ;; The first shufflevector, since it is materializing the same value as the | |
| ;; %load in a different form, should use %load's debug location, and the | |
| ;; second shufflevector, since it replaces a chain of instructions ending with | |
| ;; the insert, should use the insert's debug location. | |
| define <4 x float> @widget(ptr %arg) !dbg !5 { | |
| ; CHECK-LABEL: define <4 x float> @widget( | |
| ; CHECK-SAME: ptr [[ARG:%.*]]) !dbg [[DBG5:![0-9]+]] { | |
| ; CHECK-NEXT: [[BB:.*:]] | |
| ; CHECK-NEXT: [[LOAD:%.*]] = load <2 x float>, ptr [[ARG]], align 4, !dbg [[DBG8:![0-9]+]] | |
| ; CHECK-NEXT: [[TMP0:%.*]] = shufflevector <2 x float> [[LOAD]], <2 x float> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison>, !dbg [[DBG8]] | |
| ; CHECK-NEXT: [[INSERTELEMENT:%.*]] = shufflevector <4 x float> <float 0.000000e+00, float poison, float poison, float poison>, <4 x float> [[TMP0]], <4 x i32> <i32 4, i32 0, i32 0, i32 0>, !dbg [[DBG9:![0-9]+]] | |
| ; CHECK-NEXT: ret <4 x float> [[INSERTELEMENT]], !dbg [[DBG10:![0-9]+]] | |
| ; | |
| bb: | |
| %load = load <2 x float>, ptr %arg, align 4, !dbg !8 | |
| %extractelement = extractelement <2 x float> %load, i32 0, !dbg !9 | |
| %insertelement = insertelement <4 x float> zeroinitializer, float %extractelement, i32 0, !dbg !10 | |
| ret <4 x float> %insertelement, !dbg !11 | |
| } | |
| !llvm.dbg.cu = !{!0} | |
| !llvm.debugify = !{!2, !3} | |
| !llvm.module.flags = !{!4} | |
| !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) | |
| !1 = !DIFile(filename: "reduced.ll", directory: "/") | |
| !2 = !{i32 4} | |
| !3 = !{i32 0} | |
| !4 = !{i32 2, !"Debug Info Version", i32 3} | |
| !5 = distinct !DISubprogram(name: "widget", linkageName: "widget", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) | |
| !6 = !DISubroutineType(types: !7) | |
| !7 = !{} | |
| !8 = !DILocation(line: 1, column: 1, scope: !5) | |
| !9 = !DILocation(line: 2, column: 1, scope: !5) | |
| !10 = !DILocation(line: 3, column: 1, scope: !5) | |
| !11 = !DILocation(line: 4, column: 1, scope: !5) | |
| ;. | |
| ; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C, file: [[META1:![0-9]+]], producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) | |
| ; CHECK: [[META1]] = !DIFile(filename: "{{.*}}reduced.ll", directory: {{.*}}) | |
| ; CHECK: [[DBG5]] = distinct !DISubprogram(name: "widget", linkageName: "widget", scope: null, file: [[META1]], line: 1, type: [[META6:![0-9]+]], scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]]) | |
| ; CHECK: [[META6]] = !DISubroutineType(types: [[META7:![0-9]+]]) | |
| ; CHECK: [[META7]] = !{} | |
| ; CHECK: [[DBG8]] = !DILocation(line: 1, column: 1, scope: [[DBG5]]) | |
| ; CHECK: [[DBG9]] = !DILocation(line: 3, column: 1, scope: [[DBG5]]) | |
| ; CHECK: [[DBG10]] = !DILocation(line: 4, column: 1, scope: [[DBG5]]) | |
| ;. |