|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt -passes=instcombine -S %s -o - | FileCheck %s |
| 3 | +;; Tests that when InstCombine replaces a bswap idiom with an intrinsic, the |
| 4 | +;; !dbg attachment from the replaced instruction is applied to all generated |
| 5 | +;; instructions, not just the last. |
| 6 | + |
| 7 | +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" |
| 8 | +target triple = "x86_64-unknown-linux-gnu" |
| 9 | + |
| 10 | +define i32 @inflate(ptr %strm) { |
| 11 | +; CHECK-LABEL: define i32 @inflate( |
| 12 | +; CHECK-SAME: ptr [[STRM:%.*]]) { |
| 13 | +; CHECK-NEXT: [[ENTRY:.*:]] |
| 14 | +; CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr [[STRM]], align 8 |
| 15 | +; CHECK-NEXT: [[TRUNC:%.*]] = trunc i64 [[TMP0]] to i32, !dbg [[DBG3:![0-9]+]] |
| 16 | +; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[TRUNC]], 65535, !dbg [[DBG3]] |
| 17 | +; CHECK-NEXT: [[MASK:%.*]] = call i32 @llvm.bswap.i32(i32 [[TMP1]]), !dbg [[DBG3]] |
| 18 | +; CHECK-NEXT: [[ADD665:%.*]] = zext i32 [[MASK]] to i64, !dbg [[DBG3]] |
| 19 | +; CHECK-NEXT: store i64 [[ADD665]], ptr [[STRM]], align 8 |
| 20 | +; CHECK-NEXT: ret i32 0 |
| 21 | +; |
| 22 | +entry: |
| 23 | + %0 = load i64, ptr %strm, align 8 |
| 24 | + %and660 = and i64 %0, 65280 |
| 25 | + %shl661 = shl i64 %and660, 8 |
| 26 | + %and663 = and i64 %0, 255 |
| 27 | + %shl664 = shl i64 %and663, 24 |
| 28 | + %add665 = or i64 %shl661, %shl664, !dbg !4 |
| 29 | + store i64 %add665, ptr %strm, align 8 |
| 30 | + ret i32 0 |
| 31 | +} |
| 32 | + |
| 33 | +!llvm.dbg.cu = !{!0} |
| 34 | +!llvm.module.flags = !{!3} |
| 35 | + |
| 36 | +!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 20.0.0git") |
| 37 | +!1 = !DIFile(filename: "/tmp/zlib_inflate.c", directory: "/tmp") |
| 38 | +!2 = !{} |
| 39 | +!3 = !{i32 2, !"Debug Info Version", i32 3} |
| 40 | +!4 = !DILocation(line: 8, column: 42, scope: !6) |
| 41 | +!5 = !DIFile(filename: "zlib_inflate.c", directory: "/tmp") |
| 42 | +!6 = distinct !DISubprogram(name: "inflate", scope: !5, file: !5, line: 622, type: !7, scopeLine: 625, unit: !0, retainedNodes: !2) |
| 43 | +!7 = distinct !DISubroutineType(types: !2) |
| 44 | +;. |
| 45 | +; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C11, file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug) |
| 46 | +; CHECK: [[META1]] = !DIFile(filename: "/tmp/zlib_inflate.c", directory: {{.*}}) |
| 47 | +; CHECK: [[DBG3]] = !DILocation(line: 8, column: 42, scope: [[META4:![0-9]+]]) |
| 48 | +; CHECK: [[META4]] = distinct !DISubprogram(name: "inflate", scope: [[META5:![0-9]+]], file: [[META5]], line: 622, type: [[META6:![0-9]+]], scopeLine: 625, spFlags: DISPFlagDefinition, unit: [[META0]], retainedNodes: [[META7:![0-9]+]]) |
| 49 | +; CHECK: [[META5]] = !DIFile(filename: "zlib_inflate.c", directory: {{.*}}) |
| 50 | +; CHECK: [[META6]] = distinct !DISubroutineType(types: [[META7]]) |
| 51 | +; CHECK: [[META7]] = !{} |
| 52 | +;. |
0 commit comments