[LLVMbugs] [Bug 11771] New: Vectors shift operator broken

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jan 16 10:05:44 PST 2012


             Bug #: 11771
           Summary: Vectors shift operator broken
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: schnetter at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The shift operator >> on int2 seems broken. The example code below extracts the
sign bit of a float2, but does not work correctly:

typedef int int2  __attribute__((__ext_vector_type__(2)));
typedef float float2  __attribute__((__ext_vector_type__(2)));

int2 signbit(float2 f)
  int bits = 8 * sizeof(float);
  return *(int2*)&f >> (int2)(bits-1);

#include <stdio.h>
int main()
  float2 x = (float2){-1.0f,-1.0f};
  int2 s = signbit(x);
  printf("%d %d\n", s.s0, s.s1);
  return 0;

I expect the output "-1 -1", but receive the output "-1 0" instead. This used
to work correctly with earlier versions of llvm 3.1svn.

I also notice that the assembler code generated for "signbit" is much more
complicated than necessary. I expect a single machine instruction, but more
than 20 instructions are generated that unpack and re-pack the vector.

I am using llvm and clang 148237.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list