https://bugs.llvm.org/show_bug.cgi?id=42917

            Bug ID: 42917
           Summary: Missed vectorization for loop with MAX
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedb...@nondot.org
          Reporter: david.bolvan...@gmail.com
                CC: llvm-bugs@lists.llvm.org

#define max(a,b) (((a) > (b))? (a) : (b))

unsigned p[512];
void vmax() {
    for (int i = 0; i < 512; i+=2) {
        p[i] = max(p[i], p[i+1]);
    }
}

int main() {
    for (int i = 0; i < 10000000; ++i) {
        vmax();
    }
}

icc -O3 vmax.c -march=haswell
0m0,096s

clang -O3 vmax.c -march=haswell
0m1,518s

clang with #pragma clang loop vectorize(enable) interleave(enable)
0m1,096s

https://godbolt.org/z/5bjKUI

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to