llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.16k stars 12.03k forks source link

Poor -Rpass-analysis=loop-vectorize diagnostic message for (acceptable) failure to vectorize Objective-C fast enumeration loops #28749

Open seanm opened 8 years ago

seanm commented 8 years ago
Bugzilla Link 28375
Version trunk
OS MacOS X
Attachments Repro case

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.

seanm commented 5 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.

seanm commented 7 years ago

FYI: still reproduces with today's clang: clang version 6.0.0 (trunk 314864) (llvm/trunk 314863)

seanm commented 8 years ago

Duplicated as rdar://27112452 for Apple folks.