[LLVMbugs] [Bug 14985] New: Be more careful about vectorizing divs.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 17 07:38:14 PST 2013


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: unassignedbugs at nondot.org
        ReportedBy: benny.kra at gmail.com
                CC: llvmbugs at cs.uiuc.edu, nrotem at apple.com
    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.



More information about the llvm-bugs mailing list