[LLVMdev] Error when cond of select instruction is a vector

Fan Dawei fandawei.s at gmail.com
Wed Oct 19 01:09:42 PDT 2011


Hi LLVMdev,

In the specification of llvm ir, the select operation can takes a condition
of vector type,
'select' Instruction Syntax:

  <result> = select *selty* <cond>, <ty> <val1>, <ty> <val2>
  *; yields ty*

  *selty* is either i1 or {<N x i1>}

Overview:

The 'select' instruction is used to choose one value based on a condition,
without branching.

If the condition is a vector of i1, then the value arguments must be vectors
of the same size, and the selection is done element by element.

However when I create a program use vector of il as the type of condition.
The back-end fails and complains:

*SplitVectorOperand Op #0: 0x2b75370: f32 = select 0x2b6c800, 0x2b75270,
0x2b75170 [ID=0]

Do not know how to split this operator's operand!*

The following program is a valid IR which passed by the checker. However the
back-end fails on all the targets I've tested, including x86, mips and
sparc. Is it a target independent bug?

 define void @main() {
entry:
  %Cy300 = alloca <4 x float>
  %Cy11a = alloca <2 x float>
  %Cy118 = alloca <2 x float>
  %Cy119 = alloca <2 x float>
  br label %B1

B1:                                               ; preds = %entry
  %0 = load <2 x float>* %Cy119
  %1 = fptosi <2 x float> %0 to <2 x i32>
  %2 = sitofp <2 x i32> %1 to <2 x float>
  %3 = fcmp ogt <2 x float> %0, zeroinitializer
  %4 = fadd <2 x float> %2, <float 1.000000e+00, float 1.000000e+00>
  %5 = select <2 x i1> %3, <2 x float> %4, <2 x float> %2
  %6 = fcmp oeq <2 x float> %2, %0
  %7 = select <2 x i1> %6, <2 x float> %0, <2 x float> %5
  store <2 x float> %7, <2 x float>* %Cy118
  %8 = load <2 x float>* %Cy118
  store <2 x float> %8, <2 x float>* %Cy11a
  ret void
}


Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111019/76b51d59/attachment.html>


More information about the llvm-dev mailing list