|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2 |
| 2 | +; RUN: opt -S -mtriple=amdgcn-- -passes=amdgpu-simplifylib < %s | FileCheck %s |
| 3 | + |
| 4 | +target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8" |
| 5 | + |
| 6 | +; sin, cos, and sincos are already defined in the module. |
| 7 | + |
| 8 | +define float @_Z3sinf(float %x) { |
| 9 | +; CHECK-LABEL: define float @_Z3sinf |
| 10 | +; CHECK-SAME: (float [[X:%.*]]) { |
| 11 | +; CHECK-NEXT: [[RESULT:%.*]] = call float asm " |
| 12 | +; CHECK-NEXT: ret float [[RESULT]] |
| 13 | +; |
| 14 | + %result = call float asm "; $0 = sin($1)","=v,v"(float %x) |
| 15 | + ret float %result |
| 16 | +} |
| 17 | + |
| 18 | +define float @_Z3cosf(float %x) { |
| 19 | +; CHECK-LABEL: define float @_Z3cosf |
| 20 | +; CHECK-SAME: (float [[X:%.*]]) { |
| 21 | +; CHECK-NEXT: [[RESULT:%.*]] = call float asm " |
| 22 | +; CHECK-NEXT: ret float [[RESULT]] |
| 23 | +; |
| 24 | + %result = call float asm "; $0 = cos($1)","=v,v"(float %x) |
| 25 | + ret float %result |
| 26 | +} |
| 27 | + |
| 28 | +define <2 x float> @_Z3sinDv2_f(<2 x float> %x) { |
| 29 | +; CHECK-LABEL: define <2 x float> @_Z3sinDv2_f |
| 30 | +; CHECK-SAME: (<2 x float> [[X:%.*]]) { |
| 31 | +; CHECK-NEXT: [[RESULT:%.*]] = call <2 x float> asm " |
| 32 | +; CHECK-NEXT: ret <2 x float> [[RESULT]] |
| 33 | +; |
| 34 | + %result = call <2 x float> asm "; $0 = sin($1)","=v,v"(<2 x float> %x) |
| 35 | + ret <2 x float> %result |
| 36 | +} |
| 37 | + |
| 38 | +define <2 x float> @_Z3cosDv2_f(<2 x float> %x) { |
| 39 | +; CHECK-LABEL: define <2 x float> @_Z3cosDv2_f |
| 40 | +; CHECK-SAME: (<2 x float> [[X:%.*]]) { |
| 41 | +; CHECK-NEXT: [[RESULT:%.*]] = call <2 x float> asm " |
| 42 | +; CHECK-NEXT: ret <2 x float> [[RESULT]] |
| 43 | +; |
| 44 | + %result = call <2 x float> asm "; $0 = cos($1)","=v,v"(<2 x float> %x) |
| 45 | + ret <2 x float> %result |
| 46 | +} |
| 47 | + |
| 48 | +define float @_Z6sincosfPU3AS5f(float %x, ptr addrspace(5) %ptr) { |
| 49 | +; CHECK-LABEL: define float @_Z6sincosfPU3AS5f |
| 50 | +; CHECK-SAME: (float [[X:%.*]], ptr addrspace(5) [[PTR:%.*]]) { |
| 51 | +; CHECK-NEXT: [[RESULT0:%.*]] = call float asm " |
| 52 | +; CHECK-NEXT: [[RESULT1:%.*]] = call float asm " |
| 53 | +; CHECK-NEXT: store float [[RESULT1]], ptr addrspace(5) [[PTR]], align 4 |
| 54 | +; CHECK-NEXT: ret float [[RESULT0]] |
| 55 | +; |
| 56 | + %result0 = call float asm "; $0 = sin($1)","=v,v"(float %x) |
| 57 | + %result1 = call float asm "; $0 = cos($1)","=v,v"(float %x) |
| 58 | + store float %result1, ptr addrspace(5) %ptr |
| 59 | + ret float %result0 |
| 60 | +} |
| 61 | + |
| 62 | +define <2 x float> @_Z6sincosDv2_fPU3AS5S_(<2 x float> %x, ptr addrspace(5) %ptr) { |
| 63 | +; CHECK-LABEL: define <2 x float> @_Z6sincosDv2_fPU3AS5S_ |
| 64 | +; CHECK-SAME: (<2 x float> [[X:%.*]], ptr addrspace(5) [[PTR:%.*]]) { |
| 65 | +; CHECK-NEXT: [[RESULT0:%.*]] = call <2 x float> asm " |
| 66 | +; CHECK-NEXT: [[RESULT1:%.*]] = call <2 x float> asm " |
| 67 | +; CHECK-NEXT: store <2 x float> [[RESULT1]], ptr addrspace(5) [[PTR]], align 8 |
| 68 | +; CHECK-NEXT: ret <2 x float> [[RESULT0]] |
| 69 | +; |
| 70 | + %result0 = call <2 x float> asm "; $0 = sin($1)","=v,v"(<2 x float> %x) |
| 71 | + %result1 = call <2 x float> asm "; $0 = cos($1)","=v,v"(<2 x float> %x) |
| 72 | + store <2 x float> %result1, ptr addrspace(5) %ptr |
| 73 | + ret <2 x float> %result0 |
| 74 | +} |
| 75 | + |
| 76 | +define float @_Z6sincosfPU3AS0f(float %x, ptr %ptr) { |
| 77 | +; CHECK-LABEL: define float @_Z6sincosfPU3AS0f |
| 78 | +; CHECK-SAME: (float [[X:%.*]], ptr [[PTR:%.*]]) { |
| 79 | +; CHECK-NEXT: [[RESULT0:%.*]] = call float asm " |
| 80 | +; CHECK-NEXT: [[RESULT1:%.*]] = call float asm " |
| 81 | +; CHECK-NEXT: store float [[RESULT1]], ptr [[PTR]], align 4 |
| 82 | +; CHECK-NEXT: ret float [[RESULT0]] |
| 83 | +; |
| 84 | + %result0 = call float asm "; $0 = sin($1)","=v,v"(float %x) |
| 85 | + %result1 = call float asm "; $0 = cos($1)","=v,v"(float %x) |
| 86 | + store float %result1, ptr %ptr |
| 87 | + ret float %result0 |
| 88 | +} |
| 89 | + |
| 90 | +define <2 x float> @_Z6sincosDv2_fPU3AS0S_(<2 x float> %x, ptr %ptr) { |
| 91 | +; CHECK-LABEL: define <2 x float> @_Z6sincosDv2_fPU3AS0S_ |
| 92 | +; CHECK-SAME: (<2 x float> [[X:%.*]], ptr [[PTR:%.*]]) { |
| 93 | +; CHECK-NEXT: [[RESULT0:%.*]] = call <2 x float> asm " |
| 94 | +; CHECK-NEXT: [[RESULT1:%.*]] = call <2 x float> asm " |
| 95 | +; CHECK-NEXT: store <2 x float> [[RESULT1]], ptr [[PTR]], align 8 |
| 96 | +; CHECK-NEXT: ret <2 x float> [[RESULT0]] |
| 97 | +; |
| 98 | + %result0 = call <2 x float> asm "; $0 = sin($1)","=v,v"(<2 x float> %x) |
| 99 | + %result1 = call <2 x float> asm "; $0 = cos($1)","=v,v"(<2 x float> %x) |
| 100 | + store <2 x float> %result1, ptr %ptr |
| 101 | + ret <2 x float> %result0 |
| 102 | +} |
| 103 | + |
| 104 | +define void @sincos_f32(float %x, ptr addrspace(1) nocapture writeonly %sin_out, ptr addrspace(1) nocapture writeonly %cos_out) { |
| 105 | +; CHECK-LABEL: define void @sincos_f32 |
| 106 | +; CHECK-SAME: (float [[X:%.*]], ptr addrspace(1) nocapture writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture writeonly [[COS_OUT:%.*]]) { |
| 107 | +; CHECK-NEXT: entry: |
| 108 | +; CHECK-NEXT: [[CALL:%.*]] = tail call contract float @_Z3sinf(float [[X]]) |
| 109 | +; CHECK-NEXT: store float [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 4 |
| 110 | +; CHECK-NEXT: [[CALL1:%.*]] = tail call contract float @_Z3cosf(float [[X]]) |
| 111 | +; CHECK-NEXT: store float [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 4 |
| 112 | +; CHECK-NEXT: ret void |
| 113 | +; |
| 114 | +entry: |
| 115 | + %call = tail call contract float @_Z3sinf(float %x) |
| 116 | + store float %call, ptr addrspace(1) %sin_out, align 4 |
| 117 | + %call1 = tail call contract float @_Z3cosf(float %x) |
| 118 | + store float %call1, ptr addrspace(1) %cos_out, align 4 |
| 119 | + ret void |
| 120 | +} |
| 121 | + |
| 122 | +define void @sincos_f32_value_is_same_constantfp(ptr addrspace(1) nocapture writeonly %sin_out, ptr addrspace(1) nocapture writeonly %cos_out) { |
| 123 | +; CHECK-LABEL: define void @sincos_f32_value_is_same_constantfp |
| 124 | +; CHECK-SAME: (ptr addrspace(1) nocapture writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture writeonly [[COS_OUT:%.*]]) { |
| 125 | +; CHECK-NEXT: entry: |
| 126 | +; CHECK-NEXT: [[CALL:%.*]] = tail call contract float @_Z3sinf(float 4.200000e+01) |
| 127 | +; CHECK-NEXT: store float [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 4 |
| 128 | +; CHECK-NEXT: [[CALL1:%.*]] = tail call contract float @_Z3cosf(float 4.200000e+01) |
| 129 | +; CHECK-NEXT: store float [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 4 |
| 130 | +; CHECK-NEXT: ret void |
| 131 | +; |
| 132 | +entry: |
| 133 | + %call = tail call contract float @_Z3sinf(float 42.0) |
| 134 | + store float %call, ptr addrspace(1) %sin_out, align 4 |
| 135 | + %call1 = tail call contract float @_Z3cosf(float 42.0) |
| 136 | + store float %call1, ptr addrspace(1) %cos_out, align 4 |
| 137 | + ret void |
| 138 | +} |
| 139 | + |
| 140 | +define void @sincos_v2f32(<2 x float> %x, ptr addrspace(1) nocapture writeonly %sin_out, ptr addrspace(1) nocapture writeonly %cos_out) { |
| 141 | +; GCN-LABEL: define void @sincos_v2f32 |
| 142 | +; GCN-SAME: (<2 x float> [[X:%.*]], ptr addrspace(1) nocapture writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture writeonly [[COS_OUT:%.*]]) local_unnamed_addr { |
| 143 | +; GCN-NEXT: entry: |
| 144 | +; GCN-NEXT: [[CALL:%.*]] = tail call contract <2 x float> @_Z3sinDv2_f(<2 x float> [[X]]) |
| 145 | +; GCN-NEXT: store <2 x float> [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 8 |
| 146 | +; GCN-NEXT: [[CALL1:%.*]] = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> [[X]]) |
| 147 | +; GCN-NEXT: store <2 x float> [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 8 |
| 148 | +; GCN-NEXT: ret void |
| 149 | +; |
| 150 | +; CHECK-LABEL: define void @sincos_v2f32 |
| 151 | +; CHECK-SAME: (<2 x float> [[X:%.*]], ptr addrspace(1) nocapture writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture writeonly [[COS_OUT:%.*]]) { |
| 152 | +; CHECK-NEXT: entry: |
| 153 | +; CHECK-NEXT: [[CALL:%.*]] = tail call contract <2 x float> @_Z3sinDv2_f(<2 x float> [[X]]) |
| 154 | +; CHECK-NEXT: store <2 x float> [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 8 |
| 155 | +; CHECK-NEXT: [[CALL1:%.*]] = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> [[X]]) |
| 156 | +; CHECK-NEXT: store <2 x float> [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 8 |
| 157 | +; CHECK-NEXT: ret void |
| 158 | +; |
| 159 | +entry: |
| 160 | + %call = tail call contract <2 x float> @_Z3sinDv2_f(<2 x float> %x) |
| 161 | + store <2 x float> %call, ptr addrspace(1) %sin_out, align 8 |
| 162 | + %call1 = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> %x) |
| 163 | + store <2 x float> %call1, ptr addrspace(1) %cos_out, align 8 |
| 164 | + ret void |
| 165 | +} |
| 166 | + |
| 167 | +define void @sincos_f32_nobuiltin_callsite(float %x, ptr addrspace(1) nocapture writeonly %sin_out, ptr addrspace(1) nocapture writeonly %cos_out) { |
| 168 | +; CHECK-LABEL: define void @sincos_f32_nobuiltin_callsite |
| 169 | +; CHECK-SAME: (float [[X:%.*]], ptr addrspace(1) nocapture writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture writeonly [[COS_OUT:%.*]]) { |
| 170 | +; CHECK-NEXT: entry: |
| 171 | +; CHECK-NEXT: [[CALL:%.*]] = tail call contract float @_Z3sinf(float [[X]]) #[[ATTR0:[0-9]+]] |
| 172 | +; CHECK-NEXT: store float [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 4 |
| 173 | +; CHECK-NEXT: [[CALL1:%.*]] = tail call contract float @_Z3cosf(float [[X]]) #[[ATTR0]] |
| 174 | +; CHECK-NEXT: store float [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 4 |
| 175 | +; CHECK-NEXT: ret void |
| 176 | +; |
| 177 | +entry: |
| 178 | + %call = tail call contract float @_Z3sinf(float %x) nobuiltin |
| 179 | + store float %call, ptr addrspace(1) %sin_out, align 4 |
| 180 | + %call1 = tail call contract float @_Z3cosf(float %x) nobuiltin |
| 181 | + store float %call1, ptr addrspace(1) %cos_out, align 4 |
| 182 | + ret void |
| 183 | +} |
0 commit comments