Skip to content

Commit

Permalink
Fix __builtin_convertvector escaping the closure
Browse files Browse the repository at this point in the history
The bultin construct `__builtin_convertvector(a, b)` is not a function
but rather a special kind of Expr.  Hence we need a visitor to catch
it correctly.

Signed-off-by: Giuliano Belinassi <[email protected]>
  • Loading branch information
giulianobelinassi committed Jul 19, 2024
1 parent dd90f5e commit a3e0395
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libcextract/Closure.hh
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,14 @@ class DeclClosureVisitor : public RecursiveASTVisitor<DeclClosureVisitor>
return VISITOR_CONTINUE;
}

bool VisitConvertVectorExpr(const ConvertVectorExpr *expr)
{
const TypeSourceInfo *tsi = expr->getTypeSourceInfo();
TRY_TO(TraverseTypeLoc(tsi->getTypeLoc()));

return VISITOR_CONTINUE;
}

/* -------- Types ----------------- */
bool VisitTagType(const TagType *type)
{
Expand Down
16 changes: 16 additions & 0 deletions testsuite/small/vectortype-1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* { dg-options "-Wno-everything -DCE_EXTRACT_FUNCTIONS=f -DCE_NO_EXTERNALIZATION" }*/

typedef float __v8sf __attribute__ ((__vector_size__ (32)));

typedef unsigned int __v8su __attribute__ ((__vector_size__ (32)));

typedef float __m256 __attribute__ ((__vector_size__ (32), __aligned__(32)));

typedef long long __m256i __attribute__((__vector_size__(32), __aligned__(32)));

__m256 __attribute__((__nodebug__, __min_vector_width__(256)))
f (__m256i __A) {
return (__m256)__builtin_convertvector((__v8su)__A, __v8sf);
}

/* { dg-final { scan-tree-dump "typedef float __v8sf __attribute__ \(\(__vector_size__ \(32\)\)\);" } } */

0 comments on commit a3e0395

Please sign in to comment.