[llvm] [SPIR-V] Add lowering for G_FPOWI (PR #185454)

Diego Novillo via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 08:29:04 PDT 2026


================
@@ -0,0 +1,37 @@
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-unknown-vulkan1.3-compute %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan1.3-compute %s -o - -filetype=obj | spirv-val %}
+
+; Test that llvm.powi on Vulkan targets is lowered by converting the
+; integer exponent to float with OpConvertSToF, then calling GLSL.std.450 Pow.
+
+; CHECK-DAG: %[[#ExtInstId:]] = OpExtInstImport "GLSL.std.450"
+; CHECK-DAG: %[[#F32Ty:]] = OpTypeFloat 32
+; CHECK-DAG: %[[#I32Ty:]] = OpTypeInt 32 0
+; CHECK-DAG: %[[#I64Ty:]] = OpTypeInt 64 0
+
+; CHECK-LABEL: Begin function test_powi_f32_i32
+; CHECK: %[[#base32:]] = OpFunctionParameter %[[#F32Ty]]
+; CHECK: %[[#exp32:]] = OpFunctionParameter %[[#I32Ty]]
+; CHECK: %[[#fexp32:]] = OpConvertSToF %[[#F32Ty]] %[[#exp32]]
+; CHECK: %[[#ret32:]] = OpExtInst %[[#F32Ty]] %[[#ExtInstId]] Pow %[[#base32]] %[[#fexp32]]
+; CHECK: OpReturnValue %[[#ret32]]
+; CHECK-LABEL: OpFunctionEnd
+define float @test_powi_f32_i32(float %x, i32 %n) {
----------------
dnovillo wrote:

Done.

https://github.com/llvm/llvm-project/pull/185454


More information about the llvm-commits mailing list