blob: 7202babcd4f15555adcb3fc7d1f2b2a3e69c9408 [file]
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -passes=gvn -S | FileCheck %s --check-prefixes=CHECK,MDEP
; RUN: opt < %s -passes='gvn<memoryssa>' -S | FileCheck %s --check-prefixes=CHECK,MSSA
;; Check that when GVN replaces a load of a select with a select of the values
;; that would be loaded, we propagate the debug location from the load to the
;; select, since the select is a replacement that produces the same value.
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define void @loadtree(ptr %topol, i1 %cmp168) {
; MDEP-LABEL: define void @loadtree(
; MDEP-SAME: ptr [[TOPOL:%.*]], i1 [[CMP168:%.*]]) {
; MDEP-NEXT: [[ENTRY:.*:]]
; MDEP-NEXT: [[TMP0:%.*]] = load i32, ptr null, align 4
; MDEP-NEXT: [[TMP1:%.*]] = load i32, ptr [[TOPOL]], align 4
; MDEP-NEXT: [[CMP1681:%.*]] = icmp sgt i32 [[TMP0]], [[TMP1]]
; MDEP-NEXT: [[DOT:%.*]] = select i1 [[CMP168]], ptr [[TOPOL]], ptr null, !dbg [[DBG3:![0-9]+]]
; MDEP-NEXT: [[TMP2:%.*]] = select i1 [[CMP168]], i32 [[TMP1]], i32 [[TMP0]], !dbg [[DBG9:![0-9]+]]
; MDEP-NEXT: [[CMP174_NOT473:%.*]] = icmp eq i32 [[TMP2]], 0
; MDEP-NEXT: ret void
;
; MSSA-LABEL: define void @loadtree(
; MSSA-SAME: ptr [[TOPOL:%.*]], i1 [[CMP168:%.*]]) {
; MSSA-NEXT: [[ENTRY:.*:]]
; MSSA-NEXT: [[TMP0:%.*]] = load i32, ptr null, align 4
; MSSA-NEXT: [[TMP1:%.*]] = load i32, ptr [[TOPOL]], align 4
; MSSA-NEXT: [[CMP1681:%.*]] = icmp sgt i32 [[TMP0]], [[TMP1]]
; MSSA-NEXT: [[DOT:%.*]] = select i1 [[CMP168]], ptr [[TOPOL]], ptr null, !dbg [[DBG3:![0-9]+]]
; MSSA-NEXT: [[TMP2:%.*]] = load i32, ptr [[DOT]], align 4, !dbg [[DBG9:![0-9]+]]
; MSSA-NEXT: [[CMP174_NOT473:%.*]] = icmp eq i32 [[TMP2]], 0
; MSSA-NEXT: ret void
;
entry:
%0 = load i32, ptr null, align 4
%1 = load i32, ptr %topol, align 4
%cmp1681 = icmp sgt i32 %0, %1
%. = select i1 %cmp168, ptr %topol, ptr null, !dbg !9
%2 = load i32, ptr %., align 4, !dbg !3
%cmp174.not473 = icmp eq i32 %2, 0
ret void
}
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2}
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 20.0.0git")
!1 = !DIFile(filename: "/tmp/mltaln9.c", directory: "/tmp")
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = !DILocation(line: 4, column: 22, scope: !5)
!4 = !DIFile(filename: "mltaln9.c", directory: "/tmp")
!5 = distinct !DISubprogram(name: "loadtree", scope: !4, file: !4, line: 869, type: !6, scopeLine: 870, unit: !0, retainedNodes: !8)
!6 = distinct !DISubroutineType(types: !7)
!7 = !{null}
!8 = !{}
!9 = !DILocation(line: 9, column: 22, scope: !5)
;.
; MDEP: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C11, file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
; MDEP: [[META1]] = !DIFile(filename: "{{.*}}mltaln9.c", directory: {{.*}})
; MDEP: [[DBG3]] = !DILocation(line: 9, column: 22, scope: [[META4:![0-9]+]])
; MDEP: [[META4]] = distinct !DISubprogram(name: "loadtree", scope: [[META5:![0-9]+]], file: [[META5]], line: 869, type: [[META6:![0-9]+]], scopeLine: 870, spFlags: DISPFlagDefinition, unit: [[META0]], retainedNodes: [[META8:![0-9]+]])
; MDEP: [[META5]] = !DIFile(filename: "{{.*}}mltaln9.c", directory: {{.*}})
; MDEP: [[META6]] = distinct !DISubroutineType(types: [[META7:![0-9]+]])
; MDEP: [[META7]] = !{null}
; MDEP: [[META8]] = !{}
; MDEP: [[DBG9]] = !DILocation(line: 4, column: 22, scope: [[META4]])
;.
; MSSA: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C11, file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
; MSSA: [[META1]] = !DIFile(filename: "{{.*}}mltaln9.c", directory: {{.*}})
; MSSA: [[DBG3]] = !DILocation(line: 9, column: 22, scope: [[META4:![0-9]+]])
; MSSA: [[META4]] = distinct !DISubprogram(name: "loadtree", scope: [[META5:![0-9]+]], file: [[META5]], line: 869, type: [[META6:![0-9]+]], scopeLine: 870, spFlags: DISPFlagDefinition, unit: [[META0]], retainedNodes: [[META8:![0-9]+]])
; MSSA: [[META5]] = !DIFile(filename: "{{.*}}mltaln9.c", directory: {{.*}})
; MSSA: [[META6]] = distinct !DISubroutineType(types: [[META7:![0-9]+]])
; MSSA: [[META7]] = !{null}
; MSSA: [[META8]] = !{}
; MSSA: [[DBG9]] = !DILocation(line: 4, column: 22, scope: [[META4]])
;.
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CHECK: {{.*}}