[PATCH] Support constant expressions, including non-type template parameters, in pragma loop hints

Tyler Nowicki tnowicki at apple.com
Wed Jul 30 14:58:13 PDT 2014


Hi Aaron,

Thanks for the review! I applied your suggestions except for the following.

>> #include "clang/AST/Decl.h"
>> +#include "clang/AST/Expr.h"
> 
> This include should not be required here.

This is required to call printPretty on the value expression in LoopHintAttr.

>> diff --git a/test/CodeGen/pragma-loop.cpp b/test/CodeGen/pragma-loop.cpp
>> index b75c7ee..87f2d06 100644
>> --- a/test/CodeGen/pragma-loop.cpp
>> +++ b/test/CodeGen/pragma-loop.cpp
> 
> This file should actually be in CodeGenCXX (especially since it now
> has templates, etc). I hadn't noticed this before, sorry!

I’ll commit this move first, separately. The attached patch doesn’t have the moved test in it though.


> I'd like to see a test added for constant expressions that are a
> nonsense parsing error, just to make sure we recover properly.

I’m not exactly sure what you mean. I added:

const int VV = 4;
#pragma clang loop vectorize_width(VV +/ 2)
#pragma clang loop vectorize_width(VV + undefined)

And pre-existing were tests for

#pragma clang loop vectorize_width(Vec) interleave_count(I)  //Vec is undefined
#pragma clang loop vectorize_width(Vec) interleave_count(Int) //Int is undefined
#pragma clang loop vectorize_width(1 +) 1
#pragma clang loop vectorize_width(1) +1
#pragma clang loop interleave(*)
#pragma clang loop unroll(=)
#pragma clang loop vectorize_width(^)
#pragma clang loop interleave_count(/)
#pragma clang loop unroll_count(==)

Is there any other constant expressions you think I should test?

Tyler

-------------- next part --------------
A non-text attachment was scrubbed...
Name: loop_hint_constant_expression-svn.patch
Type: application/octet-stream
Size: 402 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140730/fbf56f84/attachment.obj>


More information about the cfe-commits mailing list