Issue 185558
Summary Missed Optimization: Failure to vectorize scalar loads and comparisons into a single vector operation
Labels new issue
Assignees
Reporter dreamking60
    ```
define i1 @src(ptr %arg0, ptr %arg1) {
 %v0 = load <2 x float>, ptr %arg1, align 8
  %v1 = load float, ptr %arg0, align 4
  %v2 = extractelement <2 x float> %v0, i64 0
  %v3 = fcmp une float %v1, %v2
  %v4 = getelementptr inbounds nuw i8, ptr %arg0, i64 4
 %v5 = load float, ptr %v4, align 4
  %v6 = extractelement <2 x float> %v0, i64 1
  %v7 = fcmp une float %v5, %v6
  %v8 = select i1 %v3, i1 true, i1 %v7
  ret i1 %v8
}

define i1 @tgt(ptr %arg0, ptr %arg1) {
  %vec_arg0 = load <2 x float>, ptr %arg0, align 4
  %vec_arg1 = load <2 x float>, ptr %arg1, align 8
  %cmp_result_vec = fcmp une <2 x float> %vec_arg0, %vec_arg1
  %res0 = extractelement <2 x i1> %cmp_result_vec, i64 0
  %res1 = extractelement <2 x i1> %cmp_result_vec, i64 1
  %final_res = select i1 %res0, i1 true, i1 %res1
  ret i1 %final_res
}
```
godbolt: https://godbolt.org/z/TE1czre66
alive2: https://alive2.llvm.org/ce/z/eqjwqJ

Pattern found in: https://github.com/dtcxzyw/llvm-opt-benchmark/blob/main/bench/pbrt-v4/optimized/imgtool.ll
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to