Skip to content

Commit

Permalink
add support for ldexp in longvectorloweringpass (#1286)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjodinchr authored Jan 4, 2024
1 parent 02ef78e commit 2d6ceb6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/LongVectorLoweringPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ Function *getBIFScalarVersion(Function &Builtin) {
case clspv::Builtins::kHalfRsqrt:
case clspv::Builtins::kHalfSin:
case clspv::Builtins::kHalfTan:
case clspv::Builtins::kLdexp:
case clspv::Builtins::kLog:
case clspv::Builtins::kLog2:
case clspv::Builtins::kMax:
Expand Down
37 changes: 37 additions & 0 deletions test/LongVectorLowering/ldexp.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
; RUN: clspv-opt --passes=long-vector-lowering %s -o %t.ll
; RUN: FileCheck %s < %t.ll

target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir-unknown-unknown"

define spir_kernel void @test(ptr addrspace(1) %x, ptr addrspace(1) %k) {
entry:
%0 = load <8 x float>, ptr addrspace(1) %x, align 32
%1 = load <8 x i32>, ptr addrspace(1) %k, align 32
%call = call spir_func <8 x float> @_Z5ldexpDv8_fDv8_i(<8 x float> %0, <8 x i32> %1)
store <8 x float> %call, ptr addrspace(1) %x, align 32
ret void
}

declare spir_func <8 x float> @_Z5ldexpDv8_fDv8_i(<8 x float>, <8 x i32>)

; CHECK-LABEL: @test
; CHECK-NOT: call spir_func <8 x float> @_Z5ldexpDv8_fDv8_i
; CHECK-COUNT-8: {{.*}} = call spir_func float @_Z5ldexpfi(float {{.*}}, i32 {{.*}})
; CHECK-NOT: call spir_func <8 x float> @_Z5ldexpDv8_fDv8_i

define spir_kernel void @test2(ptr addrspace(1) %x, ptr addrspace(1) %k) {
entry:
%0 = load <16 x float>, ptr addrspace(1) %x, align 32
%1 = load i32, ptr addrspace(1) %k, align 32
%call = call spir_func <16 x float> @_Z5ldexpDv16_fi(<16 x float> %0, i32 %1)
store <16 x float> %call, ptr addrspace(1) %x, align 32
ret void
}

declare spir_func <16 x float> @_Z5ldexpDv16_fi(<16 x float>, i32)

; CHECK-LABEL: @test2
; CHECK-NOT: call spir_func <16 x float> @_Z5ldexpDv8_fi
; CHECK-COUNT-16: {{.*}} = call spir_func float @_Z5ldexpfi(float {{.*}}, i32 {{.*}})
; CHECK-NOT: call spir_func <16 x float> @_Z5ldexpDv8_fi

0 comments on commit 2d6ceb6

Please sign in to comment.