|
| 1 | +// RUN: %clang --target=mips64-unknown-linux -S -mmadd4 %s -o -| FileCheck %s -check-prefix=MADD4 |
| 2 | +// RUN: %clang --target=mips64-unknown-linux -S -mno-madd4 %s -o -| FileCheck %s -check-prefix=NOMADD4 |
| 3 | +// RUN: %clang --target=mips64-unknown-linux -S -mmadd4 -fno-honor-nans %s -o -| FileCheck %s -check-prefix=MADD4-NONAN |
| 4 | +// RUN: %clang --target=mips64-unknown-linux -S -mno-madd4 -fno-honor-nans %s -o -| FileCheck %s -check-prefix=NOMADD4-NONAN |
| 5 | + |
| 6 | +float madd_s (float f, float g, float h) |
| 7 | +{ |
| 8 | + return (f * g) + h; |
| 9 | +} |
| 10 | +// MADD4: madd.s |
| 11 | +// NOMADD4: mul.s |
| 12 | +// NOMADD4: add.s |
| 13 | + |
| 14 | +float msub_s (float f, float g, float h) |
| 15 | +{ |
| 16 | + return (f * g) - h; |
| 17 | +} |
| 18 | +// MADD4: msub.s |
| 19 | +// NOMADD4: mul.s |
| 20 | +// NOMADD4: sub.s |
| 21 | + |
| 22 | +double madd_d (double f, double g, double h) |
| 23 | +{ |
| 24 | + return (f * g) + h; |
| 25 | +} |
| 26 | +// MADD4: madd.d |
| 27 | +// NOMADD4: mul.d |
| 28 | +// NOMADD4: add.d |
| 29 | + |
| 30 | +double msub_d (double f, double g, double h) |
| 31 | +{ |
| 32 | + return (f * g) - h; |
| 33 | +} |
| 34 | +// MADD4: msub.d |
| 35 | +// NOMADD4: mul.d |
| 36 | +// NOMADD4: sub.d |
| 37 | + |
| 38 | + |
| 39 | +float nmadd_s (float f, float g, float h) |
| 40 | +{ |
| 41 | + // FIXME: Zero has been explicitly placed to force generation of a positive |
| 42 | + // zero in IR until pattern used to match this instruction is changed to |
| 43 | + // comply with negative zero as well. |
| 44 | + return 0-((f * g) + h); |
| 45 | +} |
| 46 | +// MADD4-NONAN: nmadd.s |
| 47 | +// NOMADD4-NONAN: mul.s |
| 48 | +// NOMADD4-NONAN: add.s |
| 49 | +// NOMADD4-NONAN: sub.s |
| 50 | + |
| 51 | +float nmsub_s (float f, float g, float h) |
| 52 | +{ |
| 53 | + // FIXME: Zero has been explicitly placed to force generation of a positive |
| 54 | + // zero in IR until pattern used to match this instruction is changed to |
| 55 | + // comply with negative zero as well. |
| 56 | + return 0-((f * g) - h); |
| 57 | +} |
| 58 | +// MADD4-NONAN: nmsub.s |
| 59 | +// NOMADD4-NONAN: mul.s |
| 60 | +// NOMADD4-NONAN: sub.s |
| 61 | +// NOMADD4-NONAN: sub.s |
| 62 | + |
| 63 | +double nmadd_d (double f, double g, double h) |
| 64 | +{ |
| 65 | + // FIXME: Zero has been explicitly placed to force generation of a positive |
| 66 | + // zero in IR until pattern used to match this instruction is changed to |
| 67 | + // comply with negative zero as well. |
| 68 | + return 0-((f * g) + h); |
| 69 | +} |
| 70 | +// MADD4-NONAN: nmadd.d |
| 71 | +// NOMADD4-NONAN: mul.d |
| 72 | +// NOMADD4-NONAN: add.d |
| 73 | +// NOMADD4-NONAN: sub.d |
| 74 | + |
| 75 | +double nmsub_d (double f, double g, double h) |
| 76 | +{ |
| 77 | + // FIXME: Zero has been explicitly placed to force generation of a positive |
| 78 | + // zero in IR until pattern used to match this instruction is changed to |
| 79 | + // comply with negative zero as well. |
| 80 | + return 0-((f * g) - h); |
| 81 | +} |
| 82 | +// MADD4-NONAN: nmsub.d |
| 83 | +// NOMADD4-NONAN: mul.d |
| 84 | +// NOMADD4-NONAN: sub.d |
| 85 | +// NOMADD4-NONAN: sub.d |
| 86 | + |
0 commit comments