How do I get the Lvalue for va.hi of a ext_vector_type


This simple test case currently asserts because IRGen does not know how to generate Lvalue for
base expression “va.hi” of v2’s array reference (as in va.hi[1]).

Specifically clang asserts here (in CodeGenFunction::EmitArraySubscriptExpr):

// If the base is a vector type, then we are forming a vector element lvalue
// with this subscript.
if (E->getBase()->getType()->isVectorType()) {
// Emit the vector as an lvalue to get its address.
LValue LHS = EmitLValue(E->getBase());
assert(LHS.isSimple() && “Can only subscript lvalue vectors here!”);
return LValue::MakeVectorElt(LHS.getAddress(), Idx,
E->getBase()->getType(), LHS.getAlignment());

// Test.

#include <stdio.h>

void foo()
typedef attribute ((ext_vector_type( 4))) double double4;

double4 va;
va.hi[1] = 4.0;

Any suggestion is appreciated.

  • Fariborz