http://llvm.org/bugs/show_bug.cgi?id=14985
Bug #: 14985
Summary: Be more careful about vectorizing divs.
Product: libraries
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P
Component: Loop Optimizer
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
We vectorize this loop at -O3:
unsigned short test1(unsigned short *arr, int n) {
unsigned short reduction = 0;
for (int i = 0; i != n; ++i)
reduction += arr[i]/7;
return reduction;
}
the backend scalarizes the thing, and each div becomes a mul + some arithmetic
resulting in massive code bloat.
What we could do about it:
- BuildUDIV/BuildSDIV in TargetLowering could learn about vectors. A vector
MULHI isn't uncommon (SSE has it for 16 bit only, 32 bit could be efficiently
custom lowered; ARM supplies a MULHI for all vectors afaik)
- Raise the vectorizer cost for divisions. I'm not aware of a target that has a
SIMD integer division and the scalar version is really slow most of the time,
so it doesn't make sense to vectorize it.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs