[cfe-users] Question about ASTContext::getParents(): How to avoid empty list return?

2016-12-10 Thread Klaus Leppkes via cfe-users
Hi,

my problem is that in some cases ASTContext::getParents() returns an empty
list, reproducible with release_38 and 39, so I think it's not a bug and I
missed an important point.

a) To understand the problem: In which cases does getParents() return an
empty list and in which is doesn't?

b) Is there an easier way to get just the parent of an ASTNode?

I am working on a clang tool which (should) insert strings to convert
implicit casts to explicit casts withins C++ Code.

Internally I need to get the parent AST Node (decl or stmt) of each implicit
cast Node (I'm using an ResursiveASTVisior approach) to determ if the cast
was already handled correctly.

Any help is welcome.

Cheers,
Klaus

In my small testcase it surprisingly depends on whether or not an
implicit cast is part of an include file (uncomment b=7.0 to see the
effect). All other transformation to test.cpp are working fine.

//BEGIN test.cpp:
#include "test.hpp"
void test() {
double dblx=17.3;
int implicitcast1=dblx/2;
int cstylecast=(int)dblx/2;
}
//END test.cpp

//BEGIN test.hpp:
void foo() {
int a=7;
// int b=7.0; // if this line here is not commented out, it fails:(
}
//END test.hpp

My code looks like:

bool VisitStmt(Stmt *stmt) {
if(ImplicitCastExpr* impcast = dyn_cast(stmt)) {
CastKind kind = impcast->getCastKind();

if(kind==CK_FloatingToIntegral) {
llvm::outs() << "CK_FloatingToIntegral found \n";
//dump_location(stmt->getLocStart());
//impcast->dump();
auto parents = Context->getParents(*stmt);
if ( !parents.empty() ) {
const Decl* decl = parents[0].get();
if(decl)
instrument_Implicit_cast(impcast);
else {
const Stmt *ST = parents[0].get();
if(const CStyleCastExpr* ccast =
dyn_cast(ST)) {
llvm::outs() << "CStyle cast found\n";
}
else if(const CXXStaticCastExpr* cppcast =
dyn_cast(ST)) {
llvm::outs() << "static_cast found\n";
}
else {
instrument_Implicit_cast(impcast);
}
}
}
else {
llvm::outs() << "parents empty:(\n";
}
}
else {
//llvm::outs() << "ignored\n";
}
}
return true;
}

___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] floor is vectorized, but not sin, cos or exp

2018-12-11 Thread Klaus Leppkes via cfe-users

Hi,

according to the doc 
(https://releases.llvm.org/7.0.0/docs/Vectorizers.html) floor, sin, cos 
should be vectorized.


I can confirm (using the great https://gcc.godbolt.org/ tool) that using 
the flags "-Ofast -mavx2  -fopenmp -ffast-math" the right avx2 opcode 
(vroundps) is emited for floor (in foo), but unfortunately not for sin, 
cos or exp (e.g. see sin in bar below).


GCC 8.1+ and the Intel Compiler icc 13+ insert call to vectorized 
implementations (_ZGVbN4v_sinf or __svml_sinf4 ), but clang seems to 
have nothing like this.


Here is my small testcode:

#include

voidfoo(float* __restrict__attribute((aligned(32))) x
, float* __restrict__attribute((aligned(32))) y) {
for(inti = 0; i < 4; ++i)
y[i] = floor(x[i]);
}


voidbar(float* __restrict__attribute((aligned(32))) x
, float* __restrict__attribute((aligned(32))) y) {
for(inti = 0; i < 4; ++i)
y[i] = sin(x[i]);
}

I have reproduced this behavior on different machines. Maybe I am doing 
s.th. wrong here, but it seems like there is no vectorized 
implementation for sin, cos etc. I am using h2lib for now 
(http://h2lib.org/doc/d1/d89/simd__avx_8h_source.html) as a workaround, 
but I expect clang to do this job.


Can anybody comment on this please?

Cheers
Klaus
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] floor is vectorized, but sin, cos exp are not

2018-12-17 Thread Klaus Leppkes via cfe-users

Hi,

according to the doc 
(https://releases.llvm.org/7.0.0/docs/Vectorizers.html) floor, sin, cos 
should be vectorized.


I can confirm (using the great https://gcc.godbolt.org/ tool) that using 
the flags "-Ofast -mavx2  -fopenmp -ffast-math" the right avx2 opcode 
(vroundps) is emited for floor (in foo), but unfortunately not for sin, 
cos or exp (e.g. see sin in bar below).


GCC 8.1+ and the Intel Compiler icc 13+ insert call to vectorized 
implementations (_ZGVbN4v_sinf or __svml_sinf4 ), but clang seems to 
have nothing like this.


Here is my small testcode:

#include

voidfoo(float* __restrict__attribute((aligned(32))) x
, float* __restrict__attribute((aligned(32))) y) {
for(inti = 0; i < 4; ++i)
y[i] = floor(x[i]);
}


voidbar(float* __restrict__attribute((aligned(32))) x
, float* __restrict__attribute((aligned(32))) y) {
for(inti = 0; i < 4; ++i)
y[i] = sin(x[i]);
}

I have reproduced this behavior on different machines. Maybe I am doing 
s.th. wrong here, but it seems like there is no vectorized 
implementation for sin, cos etc. I am using h2lib for now 
(http://h2lib.org/doc/d1/d89/simd__avx_8h_source.html) as a workaround, 
but I expect clang to do this job.


Can anybody comment on this please?

Cheers
Klaus


smime.p7s
Description: S/MIME Cryptographic Signature
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users