| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| ; RUN: opt -S -p=reassociate < %s | FileCheck %s |
| |
| ;; When reassociating the expression below, we reduce it to using a single |
| ;; multiply and as part of that we generate a sub that negates one of the |
| ;; original terms; this negation "neg" should use the original expression's |
| ;; source location. |
| |
| define i32 @foo(i64 %0, i64 %1) { |
| ; CHECK-LABEL: define i32 @foo( |
| ; CHECK-SAME: i64 [[TMP0:%.*]], i64 [[TMP1:%.*]]) { |
| ; CHECK-NEXT: [[ENTRY:.*:]] |
| ; CHECK-NEXT: [[NEG:%.*]] = sub i64 0, [[TMP1]], !dbg [[DBG3:![0-9]+]] |
| ; CHECK-NEXT: [[REASS_ADD:%.*]] = add i64 [[NEG]], [[TMP0]] |
| ; CHECK-NEXT: [[REASS_MUL:%.*]] = mul i64 [[REASS_ADD]], 1000, !dbg [[DBG3]] |
| ; CHECK-NEXT: store i64 [[REASS_MUL]], ptr null, align 8 |
| ; CHECK-NEXT: ret i32 0 |
| ; |
| entry: |
| %mul1026 = mul i64 %0, 1000 |
| %add1028 = or i64 %mul1026, 0 |
| %mul1029 = mul i64 %1, 1000 |
| %sub1032 = sub i64 %add1028, %mul1029, !dbg !4 |
| store i64 %sub1032, ptr null, align 8 |
| ret i32 0 |
| } |
| |
| !llvm.dbg.cu = !{!0} |
| !llvm.module.flags = !{!3} |
| |
| !0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 20.0.0git") |
| !1 = !DIFile(filename: "test.c", directory: "/tmp") |
| !2 = !{} |
| !3 = !{i32 2, !"Debug Info Version", i32 3} |
| !4 = !DILocation(line: 10, column: 53, scope: !5) |
| !5 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 550, type: !7, scopeLine: 557, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) |
| !7 = distinct !DISubroutineType(types: !2) |
| ;. |
| ; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C11, file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug) |
| ; CHECK: [[META1]] = !DIFile(filename: "test.c", directory: {{.*}}) |
| ; CHECK: [[DBG3]] = !DILocation(line: 10, column: 53, scope: [[META4:![0-9]+]]) |
| ; CHECK: [[META4]] = distinct !DISubprogram(name: "foo", scope: [[META1]], file: [[META1]], line: 550, type: [[META5:![0-9]+]], scopeLine: 557, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META6:![0-9]+]]) |
| ; CHECK: [[META5]] = distinct !DISubroutineType(types: [[META6]]) |
| ; CHECK: [[META6]] = !{} |
| ;. |