|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple thumbv8.1-m.main -mattr=+dsp < %s | FileCheck %s |
| 3 | +; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple thumbv8.1-m.main < %s | FileCheck %s --check-prefix=CHECK-NO-DSP |
| 4 | + |
| 5 | +define i64 @test(i16 %a, i16 %b) { |
| 6 | +; CHECK-LABEL: 'test' |
| 7 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %as = sext i16 %a to i32 |
| 8 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bs = sext i16 %b to i32 |
| 9 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %m = mul i32 %as, %bs |
| 10 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ms = sext i32 %m to i64 |
| 11 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ms |
| 12 | +; |
| 13 | +; CHECK-NO-DSP-LABEL: 'test' |
| 14 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %as = sext i16 %a to i32 |
| 15 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bs = sext i16 %b to i32 |
| 16 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %m = mul i32 %as, %bs |
| 17 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ms = sext i32 %m to i64 |
| 18 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ms |
| 19 | +; |
| 20 | + %as = sext i16 %a to i32 |
| 21 | + %bs = sext i16 %b to i32 |
| 22 | + %m = mul i32 %as, %bs |
| 23 | + %ms = sext i32 %m to i64 |
| 24 | + ret i64 %ms |
| 25 | +} |
| 26 | + |
| 27 | +define i64 @withadd(i16 %a, i16 %b, i64 %c) { |
| 28 | +; CHECK-LABEL: 'withadd' |
| 29 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %as = sext i16 %a to i32 |
| 30 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bs = sext i16 %b to i32 |
| 31 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %m = mul i32 %as, %bs |
| 32 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ms = sext i32 %m to i64 |
| 33 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r = add i64 %c, %ms |
| 34 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %r |
| 35 | +; |
| 36 | +; CHECK-NO-DSP-LABEL: 'withadd' |
| 37 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %as = sext i16 %a to i32 |
| 38 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bs = sext i16 %b to i32 |
| 39 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %m = mul i32 %as, %bs |
| 40 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ms = sext i32 %m to i64 |
| 41 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r = add i64 %c, %ms |
| 42 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %r |
| 43 | +; |
| 44 | + %as = sext i16 %a to i32 |
| 45 | + %bs = sext i16 %b to i32 |
| 46 | + %m = mul i32 %as, %bs |
| 47 | + %ms = sext i32 %m to i64 |
| 48 | + %r = add i64 %c, %ms |
| 49 | + ret i64 %r |
| 50 | +} |
| 51 | + |
| 52 | +define i64 @withloads(ptr %pa, ptr %pb, i64 %c) { |
| 53 | +; CHECK-LABEL: 'withloads' |
| 54 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = load i16, ptr %pa, align 2 |
| 55 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %b = load i16, ptr %pb, align 2 |
| 56 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %as = sext i16 %a to i32 |
| 57 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %bs = sext i16 %b to i32 |
| 58 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %m = mul i32 %as, %bs |
| 59 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ms = sext i32 %m to i64 |
| 60 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r = add i64 %c, %ms |
| 61 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %r |
| 62 | +; |
| 63 | +; CHECK-NO-DSP-LABEL: 'withloads' |
| 64 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = load i16, ptr %pa, align 2 |
| 65 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %b = load i16, ptr %pb, align 2 |
| 66 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %as = sext i16 %a to i32 |
| 67 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %bs = sext i16 %b to i32 |
| 68 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %m = mul i32 %as, %bs |
| 69 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ms = sext i32 %m to i64 |
| 70 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r = add i64 %c, %ms |
| 71 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %r |
| 72 | +; |
| 73 | + %a = load i16, ptr %pa |
| 74 | + %b = load i16, ptr %pb |
| 75 | + %as = sext i16 %a to i32 |
| 76 | + %bs = sext i16 %b to i32 |
| 77 | + %m = mul i32 %as, %bs |
| 78 | + %ms = sext i32 %m to i64 |
| 79 | + %r = add i64 %c, %ms |
| 80 | + ret i64 %r |
| 81 | +} |
| 82 | + |
| 83 | +define i64 @different_extend_ops(i16 %a, i16 %b) { |
| 84 | +; CHECK-LABEL: 'different_extend_ops' |
| 85 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %as = sext i16 %a to i32 |
| 86 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bs = zext i16 %b to i32 |
| 87 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %m = mul i32 %as, %bs |
| 88 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ms = sext i32 %m to i64 |
| 89 | +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ms |
| 90 | +; |
| 91 | +; CHECK-NO-DSP-LABEL: 'different_extend_ops' |
| 92 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %as = sext i16 %a to i32 |
| 93 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bs = zext i16 %b to i32 |
| 94 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %m = mul i32 %as, %bs |
| 95 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %ms = sext i32 %m to i64 |
| 96 | +; CHECK-NO-DSP-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %ms |
| 97 | +; |
| 98 | + %as = sext i16 %a to i32 |
| 99 | + %bs = zext i16 %b to i32 |
| 100 | + %m = mul i32 %as, %bs |
| 101 | + %ms = sext i32 %m to i64 |
| 102 | + ret i64 %ms |
| 103 | +} |
0 commit comments