[PATCH] D97406: [Vectorizers]Improve emission of logical or/and reductions.

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 2 08:09:37 PST 2021


lebedev.ri added a comment.

In D97406#2597419 <https://reviews.llvm.org/D97406#2597419>, @ABataev wrote:

> In D97406#2597397 <https://reviews.llvm.org/D97406#2597397>, @lebedev.ri wrote:
>
>> `llvm/lib/Transforms/Vectorize/` changes should not be there, the costmodel itself should be fixed.
>
> So, do you suggest modifying `getArithmeticReductionCost` to return the correct cost for logical reductions?

Something along those lines, yes.

Also, could you please split off the instcombine change? That is basically LG.



================
Comment at: llvm/test/Transforms/InstCombine/vector-logical-reductions.ll:4-30
 define float @reduction_logical_or(<4 x float> %x) {
 ; CHECK-LABEL: @reduction_logical_or(
 ; CHECK-NEXT:    [[TMP1:%.*]] = fcmp ogt <4 x float> [[X:%.*]], <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>
-; CHECK-NEXT:    [[TMP2:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP1]])
-; CHECK-NEXT:    [[R:%.*]] = select i1 [[TMP2]], float -1.000000e+00, float 1.000000e+00
+; CHECK-NEXT:    [[TMP2:%.*]] = bitcast <4 x i1> [[TMP1]] to i4
+; CHECK-NEXT:    [[DOTNOT:%.*]] = icmp eq i4 [[TMP2]], 0
+; CHECK-NEXT:    [[R:%.*]] = select i1 [[DOTNOT]], float 1.000000e+00, float -1.000000e+00
 ; CHECK-NEXT:    ret float [[R]]
----------------
These tests are too complex, they should be just:


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97406/new/

https://reviews.llvm.org/D97406



More information about the llvm-commits mailing list