[llvm-dev] Vectors in Sparc

Chris.Dewhurst via llvm-dev llvm-dev at lists.llvm.org
Thu Jan 28 11:22:43 PST 2016


The following code is causing me problems in the Sparc back-end and I believe it's related to a lot of issues that I have, so I'd love to work out what I need to do to resolve this. I'm currently not making much headway into it. I'm going to try to simplify this to the core problem I can see and hope I haven't missed anything relevant.

The original code I have is as follows:

typedef char vec8 __attribute__((vector_size(4)));

extern vec8 foo1_8(void);
extern vec8 foo2_8(void);

vec8 fun8(void)
{
  return foo1_8 () & foo2_8 ();
}

On x86, this compiles into this IR:

; Function Attrs: nounwind uwtable
define i32 @fun8() #0 !dbg !4 {
  %1 = tail call i32 @foo1_8() #2, !dbg !23
  %2 = tail call i32 @foo2_8() #2, !dbg !24
  %3 = and i32 %2, %1, !dbg !26
  ret i32 %3, !dbg !27
}

On Sparc, this compiles into this IR:

; Function Attrs: nounwind
define <4 x i8> @fun8() #0 !dbg !4 {
  %1 = tail call <4 x i8> @foo1_8() #2, !dbg !23
  %2 = tail call <4 x i8> @foo2_8() #2, !dbg !24
  %3 = and <4 x i8> %2, %1, !dbg !26
  ret <4 x i8> %3, !dbg !27
}

When I try to compile this down to an object file using llc, I get this error for Sparc (none for x86):

   LowerCall didn't emit the correct number of values!

It appears that the Sparc system doesn't know how to lower calls using vectors. I need to either be able to (1) Work out how to get clang to compile the Sparc code into something more similar to the x86 code, or (2) to work out how to get the llc backend for sparc to know how to lower calls containing vectors.

I'd prefer to do the first of these and get the vectors represented as registers. This seems more efficient.

Any help pointing me in the right direction will be greatly appreciated. I don't suppose there's anything as simple a a clang command-line flag that will do this???

Chris Dewhurst,
LERO, The Irish Software Research Centre,
University of Limerick.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160128/fea79406/attachment.html>


More information about the llvm-dev mailing list