Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

CellSPU assert C != 0 && "LowerEXTRACT_VECTOR_ELT expecting constant SDNode" #3371

Closed Quuxplusone closed 14 years ago

Quuxplusone commented 16 years ago
Bugzilla Link PR3056
Status RESOLVED FIXED
Importance P normal
Reported by Brian Watt (bwatt@us.ibm.com)
Reported on 2008-11-12 09:59:13 -0800
Last modified on 2010-02-22 12:56:15 -0800
Version trunk
Hardware PC Linux
CC llvm-bugs@lists.llvm.org, scooter.phd@gmail.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
For C-language code:

typedef float float4 __attribute__((ext_vector_type(4)));

float check(int i) {
    float4 a = {1.0f,2.0f,3.0f,4.0f};
    return a[i];
}

Which produces LLVM IR (after optimization):

; ModuleID = 'test-float4'
target datalayout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-
f32:32:32-f64:64:64-v128:128:128"
target triple = "ppc-unknown-linux-gnu"

define float @check(i32 %i) nounwind readnone {
entry:
    %0 = extractelement <4 x float> < float 1.000000e+00, float 2.000000e+00,
float 3.000000e+00, float 4.000000e+00 >, i32 %i        ; <float> [#uses=1]
    ret float %0
}

Produces the following assertion failure for CellSPU:

llc: SPUISelLowering.cpp:2044: llvm::SDValue
LowerEXTRACT_VECTOR_ELT(llvm::SDValue, llvm::SelectionDAG&): Assertion `C != 0
&& "LowerEXTRACT_VECTOR_ELT expecting constant SDNode"' failed.
Quuxplusone commented 15 years ago

Only constant element extraction is currently implemented in the code.

Quuxplusone commented 15 years ago

Fixed by revision 59891.

Quuxplusone commented 15 years ago
Now producing IR as follows:

; ModuleID = 'test-float4'
target datalayout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-
f32:32:32-f64:64:64-v128:128:128"
target triple = "ppc-unknown-linux-gnu"

define float @check(i32 %i) nounwind readnone {
entry:
    %vecext = extractelement <4 x float> < float 1.000000e+00, float 2.000000e+00,
float 3.000000e+00, float 4.000000e+00 >, i32 %i        ; <float> [#uses=1]
    ret float %vecext
}

However, the resulting Cell SPU assembler code now produces:

    .text

    .section    .rodata.cst16,"aM",@progbits,16
    .align  4
.LCPI1_0:
    .long   1065353216  # float 1.000000e+00
    .long   1073741824  # float 2.000000e+00
    .long   1077936128  # float 3.000000e+00
    .long   1082130432  # float 4.000000e+00
    .text
    .align  3
    .global check
    .type   check, @function
check:
    lqa $4, .LCPI1_0
    shli    $3, $3, 2
    ila $5, 66051
    shlqbyi $3, $4, $3
    shufb   $3, $3, $3, $5
.Llabel1:
    bi  $lr
    .size   check,.-check

Which when compiled with spu-as, I produces an assembler warning

spu-as -g -o test-float4.o test-float4.s # test-float4.o
test-float4.s: Assembler messages:
test-float4.s:19: Warning: Treating '$3' as a symbol.

It appears to be warning that "shlqbyi $3, $4, $3" should have an immediate
value and not a register in the last operand.

As a result, I am reopening this bug. Sorry.
Quuxplusone commented 15 years ago

Typo in instruction mnemonic. Fixed.