|
| 1 | +; RUN: opt -load-pass-plugin %llvmshlibdir/FmuladdMergePass_MarkinIvan_FIIT2_LLVM_IR%pluginext \ |
| 2 | +; RUN: -passes="FmulFaddMergePass" -S %s | FileCheck %s |
| 3 | + |
| 4 | +; CHECK-LABEL: @fmaDouble |
| 5 | +; CHECK: call double @llvm.fmuladd.f64(double %A, double %B, double %C) |
| 6 | +; CHECK-NOT: fmul |
| 7 | +; CHECK-NOT: fadd |
| 8 | +define dso_local noundef double @fmaDouble(double %A, double %B, double %C) { |
| 9 | +entry: |
| 10 | + %mul = fmul contract double %A, %B |
| 11 | + %add = fadd contract double %mul, %C |
| 12 | + ret double %add |
| 13 | +} |
| 14 | + |
| 15 | +; CHECK-LABEL: @fmaFloat |
| 16 | +; CHECK: call float @llvm.fmuladd.f32(float %A, float %B, float %C) |
| 17 | +; CHECK-NOT: fmul |
| 18 | +; CHECK-NOT: fadd |
| 19 | +define dso_local noundef float @fmaFloat(float %A, float %B, float %C) { |
| 20 | +entry: |
| 21 | + %mul = fmul contract float %A, %B |
| 22 | + %add = fadd contract float %mul, %C |
| 23 | + ret float %add |
| 24 | +} |
| 25 | + |
| 26 | +; CHECK-LABEL: @recursiveTest |
| 27 | +; CHECK: call float @llvm.fmuladd.f32(float %add1, float %B, float %add) |
| 28 | +; CHECK-NOT: fmul |
| 29 | +; CHECK-NOT: fadd |
| 30 | +define dso_local noundef float @recursiveTest(float %A, float %B, float %C) { |
| 31 | +entry: |
| 32 | + %add = fadd contract float %B, %C |
| 33 | + %add1 = fadd contract float %A, %B |
| 34 | + %mul = fmul contract float %add1, %B |
| 35 | + %add2 = fadd contract float %add, %mul |
| 36 | + ret float %add2 |
| 37 | +} |
| 38 | + |
| 39 | +; CHECK-LABEL: @foo |
| 40 | +; CHECK: %0 = call float @llvm.fmuladd.f32(float %A, float %B, float %C) |
| 41 | +; CHECK: %1 = call float @llvm.fmuladd.f32(float %A, float %B, float 1.000000e+00) |
| 42 | +; CHECK: %div = fdiv float %0, %1 |
| 43 | +; CHECK-NOT: %mul = fmul contract float %A, %B |
| 44 | +; CHECK-NOT: fadd |
| 45 | +define float @foo(float %A, float %B, float %C) { |
| 46 | +entry: |
| 47 | + %mul = fmul contract float %A, %B |
| 48 | + %add = fadd contract float %mul, %C |
| 49 | + %add1 = fadd contract float %mul, 1.000000e+00 |
| 50 | + %div = fdiv float %add, %add1 |
| 51 | + ret float %div |
| 52 | +} |
| 53 | +; CHECK-LABEL: @noContract |
| 54 | +; CHECK: fmul float %A, %B |
| 55 | +; CHECK: fadd float %mul, %C |
| 56 | +define float @noContract(float %A, float %B, float %C) { |
| 57 | +entry: |
| 58 | + %mul = fmul float %A, %B |
| 59 | + %add = fadd float %mul, %C |
| 60 | + ret float %add |
| 61 | +} |
| 62 | +; CHECK-LABEL: @multipleFMA |
| 63 | +; CHECK: call float @llvm.fmuladd.f32(float %A, float %B, float %C) |
| 64 | +; CHECK: call float @llvm.fmuladd.f32(float %D, float %E, float %F) |
| 65 | +define float @multipleFMA(float %A, float %B, float %C, float %D, float %E, float %F) { |
| 66 | +entry: |
| 67 | + %mul1 = fmul contract float %A, %B |
| 68 | + %add1 = fadd contract float %mul1, %C |
| 69 | + %mul2 = fmul contract float %D, %E |
| 70 | + %add2 = fadd contract float %mul2, %F |
| 71 | + ret float %add2 |
| 72 | +} |
| 73 | +; CHECK-LABEL: @differentArduments |
| 74 | +; CHECK: fmul contract float %A, %B |
| 75 | +; CHECK: fadd contract float %B, %D |
| 76 | +define float @differentArduments(float %A, float %B, float %D) { |
| 77 | +entry: |
| 78 | + %mul = fmul contract float %A, %B |
| 79 | + %add = fadd contract float %B, %D |
| 80 | + ret float %add |
| 81 | +} |
| 82 | +; CHECK-LABEL: @differentInstructions |
| 83 | +; CHECK: fadd contract float %A, %B |
| 84 | +; CHECK: fadd contract float %add1, %D |
| 85 | +define float @differentInstructions(float %A, float %B, float %D) { |
| 86 | +entry: |
| 87 | + %add1 = fadd contract float %A, %B |
| 88 | + %add = fadd contract float %add1, %D |
| 89 | + ret float %add |
| 90 | +} |
0 commit comments