llvm-project/llvm/test/Transforms/NaryReassociate
Evgeniy Brevnov 36b932d6a3 [NARY] Don't optimize min/max if there are side uses
Say we have
%1=min(%a,%b)
%2=min(%b,%c)
%3=min(%2,%a)

The optimization will try to reassociate the later one so that we can rewrite it to %3=min(%1, %c) and remove %2.
But if %2 has another uses outside of %3 then we can't remove %2 and end up with:

%1=min(%a,%b)
%2=min(%b,%c)
%3=min(%1, %c)

This doesn't harm by itself except it is not profitable and changes IR for no good reason.
What is bad it triggers next iteration which finds out that optimization is applicable to %2 and %3 and generates:

%1=min(%a,%b)
%2=min(%b,%c)
%3=min(%1,%c)
%4=min(%2,%a)

and so on...

The solution is to prevent optimization in the first place if intermediate result (%2) has side uses and
known to be not removed.

Reviewed By: mkazantsev

Differential Revision: https://reviews.llvm.org/D100170
2021-04-12 12:43:54 +07:00
..
NVPTX
nary-add.ll
nary-mul.ll
nary-req.ll [NARY] Don't optimize min/max if there are side uses 2021-04-12 12:43:54 +07:00
nary-smax.ll [NARY-REASSOCIATE] Support reassociation of min/max 2021-04-02 15:30:13 +07:00
nary-smin.ll [NARY-REASSOCIATE] Support reassociation of min/max 2021-04-02 15:30:13 +07:00
nary-umax.ll [NARY-REASSOCIATE] Support reassociation of min/max 2021-04-02 15:30:13 +07:00
nary-umin.ll [NARY-REASSOCIATE] Support reassociation of min/max 2021-04-02 15:30:13 +07:00
pr24301.ll [NARY-REASSOCIATE] Simplify traversal logic by post deleting dead instructions 2020-12-04 16:17:50 +07:00
pr35710.ll
pr37539.ll