Skip to content

[CodeGen] Intrinsic @llvm.powi.v2f64.i32 causes errors in LoongArch64 and RISCV64 when vector features are enabled. #118079

@ylzsx

Description

@ylzsx

pow.ll

define void @test_powi_v2f64(ptr %0, i32 %1) {
  %load = load <2 x double>, ptr %0, align 8
  %4 = tail call contract <2 x double> @llvm.powi.v2f64.i32(<2 x double> %load, i32 %1)
  store <2 x double> %4, ptr %0, align 8
  ret void
}

./bin/llc --mtriple=riscv64 -mattr=+v pow.ll -o -

        .text
        .attribute      4, 16
        .attribute      5, "rv64i2p1_f2p2_d2p2_v1p0_zicsr2p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0"
        .file   "pow.ll"
error: POWI exponent does not match sizeof(int)
error: POWI exponent does not match sizeof(int)
        .globl  test_powi_v2f64                 # -- Begin function test_powi_v2f64
        .p2align        2
        .type   test_powi_v2f64,@function
test_powi_v2f64:                        # @test_powi_v2f64
        .cfi_startproc
# %bb.0:
        vsetivli        zero, 2, e64, m1, ta, ma
        vfslide1down.vf v8, v8, fa5
        vse64.v v8, (a0)
        ret
.Lfunc_end0:
        .size   test_powi_v2f64, .Lfunc_end0-test_powi_v2f64
        .cfi_endproc
                                        # -- End function
        .section        ".note.GNU-stack","",@progbit

./bin/llc --mtriple=loongarch64 -mattr=+lsx pow.ll -o -

        .text
        .file   "pow.ll"
error: POWI exponent does not match sizeof(int)
error: POWI exponent does not match sizeof(int)
        .globl  test_powi_v2f64                 # -- Begin function test_powi_v2f64
        .p2align        5
        .type   test_powi_v2f64,@function
test_powi_v2f64:                        # @test_powi_v2f64
        .cfi_startproc
# %bb.0:
        vinsgr2vr.d     $vr0, $a0, 0
        vinsgr2vr.d     $vr0, $a0, 1
        vst     $vr0, $a0, 0
        ret
.Lfunc_end0:
        .size   test_powi_v2f64, .Lfunc_end0-test_powi_v2f64
        .cfi_endproc
                                        # -- End function
        .section        ".note.GNU-stack","",@progbits

On both backends, this IR generates an error error: POWI exponent does not match sizeof(int) and produces the wrong instruction sequence.
I will submit a patch to fix it.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions