[PATCH] D149731: [IR] New function llvm::createMinMaxSelectCmpOp for creating min/max operation in select-cmp form
Mel Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 3 03:35:33 PDT 2023
Mel-Chen updated this revision to Diff 519026.
Mel-Chen added a comment.
Update commit log.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149731/new/
https://reviews.llvm.org/D149731
Files:
llvm/include/llvm/Transforms/Utils/LoopUtils.h
llvm/lib/Transforms/Utils/LoopUtils.cpp
Index: llvm/lib/Transforms/Utils/LoopUtils.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -940,6 +940,14 @@
return Builder.CreateSelect(Cmp, Left, Right, "rdx.select");
}
+Value *llvm::createMinMaxSelectCmpOp(IRBuilderBase &Builder, RecurKind RK,
+ Value *Left, Value *Right) {
+ CmpInst::Predicate Pred = getMinMaxReductionPredicate(RK);
+ Value *Cmp = Builder.CreateCmp(Pred, Left, Right, "rdx.minmax.cmp");
+ Value *Select = Builder.CreateSelect(Cmp, Left, Right, "rdx.minmax.select");
+ return Select;
+}
+
Value *llvm::createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left,
Value *Right) {
Type *Ty = Left->getType();
@@ -949,10 +957,7 @@
return Builder.CreateIntrinsic(Ty, Id, {Left, Right}, nullptr,
"rdx.minmax");
}
- CmpInst::Predicate Pred = getMinMaxReductionPredicate(RK);
- Value *Cmp = Builder.CreateCmp(Pred, Left, Right, "rdx.minmax.cmp");
- Value *Select = Builder.CreateSelect(Cmp, Left, Right, "rdx.minmax.select");
- return Select;
+ return createMinMaxSelectCmpOp(Builder, RK, Left, Right);
}
// Helper to generate an ordered reduction.
Index: llvm/include/llvm/Transforms/Utils/LoopUtils.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/LoopUtils.h
+++ llvm/include/llvm/Transforms/Utils/LoopUtils.h
@@ -364,6 +364,13 @@
Value *createSelectCmpOp(IRBuilderBase &Builder, Value *StartVal, RecurKind RK,
Value *Left, Value *Right);
+/// Returns a Min/Max operation in select-cmp form corresponding to
+/// MinMaxRecurrenceKind.
+/// Select(Cmp(strict min max predicate, Left, Right), Left, Right)
+/// The Builder's fast-math-flags must be set to propagate the expected values.
+Value *createMinMaxSelectCmpOp(IRBuilderBase &Builder, RecurKind RK,
+ Value *Left, Value *Right);
+
/// Returns a Min/Max operation corresponding to MinMaxRecurrenceKind.
/// The Builder's fast-math-flags must be set to propagate the expected values.
Value *createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149731.519026.patch
Type: text/x-patch
Size: 2306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230503/0a687fe5/attachment.bin>
More information about the llvm-commits
mailing list