[all-commits] [llvm/llvm-project] 04ba80: [Instcombiner]Improve emission of logical or/and r...

cilkplus via All-commits all-commits at lists.llvm.org
Thu Mar 4 08:02:12 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 04ba80ca4dee39ce5176ea241d076e5493ecbebe
      https://github.com/llvm/llvm-project/commit/04ba80ca4dee39ce5176ea241d076e5493ecbebe
  Author: Alexey Bataev <a.bataev at outlook.com>
  Date:   2021-03-04 (Thu, 04 Mar 2021)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
    M llvm/test/Transforms/InstCombine/vector-logical-reductions.ll

  Log Message:
  -----------
  [Instcombiner]Improve emission of logical or/and reductions.

For logical or/and reductions we emit regular intrinsics @llvm.vector.reduce.or/and.vxi1 calls.
These intrinsics are not effective for the logical or/and reductions,
especially if the optimizer is able to emit short circuit versions of
the scalar or/and instructions and vector code gets less effective than
the scalar version.
Instead, or reduction for i1 can be represented as:
```
%val = bitcast <ReduxWidth x i1> to iReduxWidth
%res = cmp ne iReduxWidth %val, 0
```
and reduction for i1 can be represented as:
```
%val = bitcast <ReduxWidth x i1> to iReduxWidth
%res = cmp eq iReduxWidth %val, 11111
```
This improves perfromance of the vector code significantly and make it
to outperform short circuit scalar code.

Part of D57059.

Differential Revision: https://reviews.llvm.org/D97406




More information about the All-commits mailing list