Open seanm opened 8 years ago
Just tried in trunk 347180 and clang gives more output than it used to:
$ clang -S -fvectorize -O3 -Rpass-analysis=loop-vectorize ~/Desktop/test.m /Users/sean/Desktop/test.m:6:3: remark: loop not vectorized: control flow cannot be substituted for a select [-Rpass-analysis=loop-vectorize] for (NSNumber* n in @[@1, @2, @3]) { ^ /Users/sean/Desktop/test.m:6:3: remark: loop not vectorized: call instruction cannot be vectorized [-Rpass-analysis=loop-vectorize] /Users/sean/Desktop/test.m:6:3: remark: loop not vectorized: read with atomic ordering or volatile read [-Rpass-analysis=loop-vectorize]
But I still think something like "NSFastEnumeration loops can never be vectorized" would be slicker.
FYI: still reproduces with today's clang: clang version 6.0.0 (trunk 314864) (llvm/trunk 314863)
Duplicated as rdar://27112452 for Apple folks.
Extended Description
I'm not at all surprised that clang does not autovectorize even simple Objective-C fast enumeration loops like below:
-------test.m----------
import <Foundation/Foundation.h>
int main(void) { int sum = 0; for (NSNumber* n in @[@1, @2, @3]) { sum++; } return sum; }
But the diagnostic is poor:
$ clang --version clang version 3.9.0 (trunk 274259)
$ clang -S -fvectorize -O3 -Rpass-analysis=loop-vectorize ~/Desktop/test.m /Users/sean/Desktop/test.m:6:2: remark: loop not vectorized: control flow cannot be substituted for a select [-Rpass-analysis=loop-vectorize] for (NSNumber* n in @[@6, @7, @3]) { ^
A message like "NSFastEnumeration loops can never be vectorized" would be better IMHO.