Skip to content

Add constexpr support for accessing vector elements #87369

Closed
@RKSimon

Description

@RKSimon

Building on #76615 (#46593) by @Destroyerrrocket - we don't currently support accessing vector elements in constant expressions:

typedef int __v4si __attribute__((__vector_size__(16)));

constexpr  int extract0(__v4si v) {
  return v[0];
}
constexpr __v4si insert(__v4si v, int i, int s) {
    v[i] = s;
    return v;
}

https://gcc.godbolt.org/z/zfKs5EjWc has more examples (non-constant element indices, implicit conversions etc.)

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"constexprAnything related to constant evaluationenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions