JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -asm-verbose=false | FileCheck %s |
| 2 | |
| 3 | ; Test that basic 32-bit floating-point operations assemble as expected. |
| 4 | |
Dan Gohman | dde8dce | 2015-08-19 20:30:20 +0000 | [diff] [blame] | 5 | target datalayout = "e-p:32:32-i64:64-n32:64-S128" |
JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 6 | target triple = "wasm32-unknown-unknown" |
| 7 | |
| 8 | declare float @llvm.fabs.f32(float) |
| 9 | declare float @llvm.copysign.f32(float, float) |
| 10 | declare float @llvm.sqrt.f32(float) |
Dan Gohman | 896e53f | 2015-08-24 18:23:13 +0000 | [diff] [blame^] | 11 | declare float @llvm.ceil.f32(float) |
| 12 | declare float @llvm.floor.f32(float) |
| 13 | declare float @llvm.trunc.f32(float) |
| 14 | declare float @llvm.nearbyint.f32(float) |
| 15 | declare float @llvm.rint.f32(float) |
JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 16 | |
| 17 | ; CHECK-LABEL: fadd32: |
| 18 | ; CHECK-NEXT: (setlocal @0 (argument 1)) |
| 19 | ; CHECK-NEXT: (setlocal @1 (argument 0)) |
| 20 | ; CHECK-NEXT: (setlocal @2 (fadd @1 @0)) |
| 21 | ; CHECK-NEXT: (return @2) |
| 22 | define float @fadd32(float %x, float %y) { |
| 23 | %a = fadd float %x, %y |
| 24 | ret float %a |
| 25 | } |
| 26 | |
| 27 | ; CHECK-LABEL: fsub32: |
| 28 | ; CHECK: (setlocal @2 (fsub @1 @0)) |
| 29 | define float @fsub32(float %x, float %y) { |
| 30 | %a = fsub float %x, %y |
| 31 | ret float %a |
| 32 | } |
| 33 | |
| 34 | ; CHECK-LABEL: fmul32: |
| 35 | ; CHECK: (setlocal @2 (fmul @1 @0)) |
| 36 | define float @fmul32(float %x, float %y) { |
| 37 | %a = fmul float %x, %y |
| 38 | ret float %a |
| 39 | } |
| 40 | |
| 41 | ; CHECK-LABEL: fdiv32: |
| 42 | ; CHECK: (setlocal @2 (fdiv @1 @0)) |
| 43 | define float @fdiv32(float %x, float %y) { |
| 44 | %a = fdiv float %x, %y |
| 45 | ret float %a |
| 46 | } |
| 47 | |
| 48 | ; CHECK-LABEL: fabs32: |
| 49 | ; CHECK: (setlocal @1 (fabs @0)) |
| 50 | define float @fabs32(float %x) { |
| 51 | %a = call float @llvm.fabs.f32(float %x) |
| 52 | ret float %a |
| 53 | } |
| 54 | |
| 55 | ; CHECK-LABEL: fneg32: |
| 56 | ; CHECK: (setlocal @1 (fneg @0)) |
| 57 | define float @fneg32(float %x) { |
| 58 | %a = fsub float -0., %x |
| 59 | ret float %a |
| 60 | } |
| 61 | |
| 62 | ; CHECK-LABEL: copysign32: |
| 63 | ; CHECK: (setlocal @2 (copysign @1 @0)) |
| 64 | define float @copysign32(float %x, float %y) { |
| 65 | %a = call float @llvm.copysign.f32(float %x, float %y) |
| 66 | ret float %a |
| 67 | } |
| 68 | |
| 69 | ; CHECK-LABEL: sqrt32: |
| 70 | ; CHECK: (setlocal @1 (sqrt @0)) |
| 71 | define float @sqrt32(float %x) { |
| 72 | %a = call float @llvm.sqrt.f32(float %x) |
| 73 | ret float %a |
| 74 | } |
Dan Gohman | 896e53f | 2015-08-24 18:23:13 +0000 | [diff] [blame^] | 75 | |
| 76 | ; CHECK-LABEL: ceil32: |
| 77 | ; CHECK: (setlocal @1 (ceil @0)) |
| 78 | define float @ceil32(float %x) { |
| 79 | %a = call float @llvm.ceil.f32(float %x) |
| 80 | ret float %a |
| 81 | } |
| 82 | |
| 83 | ; CHECK-LABEL: floor32: |
| 84 | ; CHECK: (setlocal @1 (floor @0)) |
| 85 | define float @floor32(float %x) { |
| 86 | %a = call float @llvm.floor.f32(float %x) |
| 87 | ret float %a |
| 88 | } |
| 89 | |
| 90 | ; CHECK-LABEL: trunc32: |
| 91 | ; CHECK: (setlocal @1 (trunc @0)) |
| 92 | define float @trunc32(float %x) { |
| 93 | %a = call float @llvm.trunc.f32(float %x) |
| 94 | ret float %a |
| 95 | } |
| 96 | |
| 97 | ; CHECK-LABEL: nearestint32: |
| 98 | ; CHECK: (setlocal @1 (nearestint @0)) |
| 99 | define float @nearestint32(float %x) { |
| 100 | %a = call float @llvm.nearbyint.f32(float %x) |
| 101 | ret float %a |
| 102 | } |
| 103 | |
| 104 | ; CHECK-LABEL: nearestint32_via_rint: |
| 105 | ; CHECK: (setlocal @1 (nearestint @0)) |
| 106 | define float @nearestint32_via_rint(float %x) { |
| 107 | %a = call float @llvm.rint.f32(float %x) |
| 108 | ret float %a |
| 109 | } |