[PATCH] D113442: [InstCombine] Enable fold select into operand for FAdd, FMul, FSub and FDiv.

Huihui Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 31 13:24:31 PST 2022


huihuiz added a comment.

Thank you guys for looking into this!

One of the optimization enabled through this patch is reduction detection. The same applies to it's integer equivalent.

Take the example test.ll attached in the very first comment
run:
opt -S -instcombine test.ll -o test2.ll
opt -polly-process-unprofitable -polly-remarks-minimal -polly-use-llvm-names -polly-codegen-verify -analyze -polly-scops test2.ll

Then you will see reduction getting detected. Eventually allow loops to get vectorized.
MustWriteAccess := [Reduction Type: +] [Scalar: 0]

The folding in particular reduce the user of %sum.014.reload to 1. So that we don't need to over-complicate the data-flow analysis algorithm used by vectorizer. Also don't need to combine multiple reduction operators.

before

  %cmp1 = fcmp fast ogt float %0, 0.000000e+00
  %add = fadd fast float %0, %sum.014.reload
  %sum.1 = select i1 %cmp1, float %add, float %sum.014.reload

after

  %.inv = fcmp fast ole float %0, -0.000000e+00
  %1 = select fast i1 %.inv, float -0.000000e+00, float %0
  %sum.1 = fadd fast float %sum.014.reload, %1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113442



More information about the llvm-commits mailing list