This patch preserves the ability to represent min max operations in select-cmp form. This provides flexibility in choosing between intrinsic or select-cmp form for generating min max operations, depending on the optimization requirements.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/Utils/LoopUtils.cpp | ||
---|---|---|
943 | I am aware that we can use intrinsic to represent min max operations, but this patch aims to preserve the ability to express min max operations in select-cmp form. This is necessary for the vectorization feature I am currently developing. It is important to emphasize that this patch does not enforce the use of select-cmp form for min max operations, but rather provides an additional option. | |
952 |
llvm/lib/Transforms/Utils/LoopUtils.cpp | ||
---|---|---|
943 | Why does your patch require the non-canonical select-cmp form? Please explain this in the patch description. |
llvm/lib/Transforms/Utils/LoopUtils.cpp | ||
---|---|---|
943 |
Can you please share so we can check it and possibly suggest some tips? |
llvm/lib/Transforms/Utils/LoopUtils.cpp | ||
---|---|---|
943 | @nikic @xbolva00 Sure. Here is the WIP patch: D143465 middle.block: ; preds = %vector.body ;; Start to fix minmax reduction %rdx.minmax.cmp = icmp sgt i64 %12, %13 %rdx.minmax.select = select i1 %rdx.minmax.cmp, i64 %12, i64 %13 %rdx.minmax.cmp8 = icmp sgt i64 %rdx.minmax.select, %14 %rdx.minmax.select9 = select i1 %rdx.minmax.cmp8, i64 %rdx.minmax.select, i64 %14 %rdx.minmax.cmp10 = icmp sgt i64 %rdx.minmax.select9, %15 %rdx.minmax.select11 = select i1 %rdx.minmax.cmp10, i64 %rdx.minmax.select9, i64 %15 ;; Start to fix index reduction %rdx.select = select i1 %rdx.minmax.cmp, i64 %20, i64 %21 %rdx.select12 = select i1 %rdx.minmax.cmp8, i64 %rdx.select, i64 %22 %rdx.select13 = select i1 %rdx.minmax.cmp10, i64 %rdx.select12, i64 %23 For the handling of index reduction, we require the cmp part of the min max operation. This is the reason why I need this patch. |
llvm/lib/Transforms/Utils/LoopUtils.cpp | ||
---|---|---|
952 | maxnum/minnum reductions are sensitive to ordering if the values might be nan |
llvm/lib/Transforms/Utils/LoopUtils.cpp | ||
---|---|---|
943 | To clarify, is the sequence below could be expressed using intrinsics, %rdx.minmax.cmp = icmp sgt i64 %12, %13 %rdx.minmax.select = select i1 %rdx.minmax.cmp, i64 %12, i64 %13 %rdx.minmax.cmp8 = icmp sgt i64 %rdx.minmax.select, %14 %rdx.minmax.select9 = select i1 %rdx.minmax.cmp8, i64 %rdx.minmax.select, i64 %14 %rdx.minmax.cmp10 = icmp sgt i64 %rdx.minmax.select9, %15 %rdx.minmax.select11 = select i1 %rdx.minmax.cmp10, i64 %rdx.minmax.select9, i64 %15 but you would like to re-use the compares from above for the selcets below: ;; Start to fix index reduction %rdx.select = select i1 %rdx.minmax.cmp, i64 %20, i64 %21 %rdx.select12 = select i1 %rdx.minmax.cmp8, i64 %rdx.select, i64 %22 %rdx.select13 = select i1 %rdx.minmax.cmp10, i64 %rdx.select12, i64 %23 If that's the case it would probably be better to just keep the min/max select generation code local to the code that generates the 2nd chain of selects, instead of exposing this as general API | |
943 |
@Mel-Chen is the comment above an accurate summary? |
llvm/lib/Transforms/Utils/LoopUtils.cpp | ||
---|---|---|
943 | @fhahn |
We have intrinsics for min and max. Do not emit cmp select form..