[llvm] 0c18415 - zz
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 10 09:10:55 PDT 2021
Author: Roman Lebedev
Date: 2021-04-10T19:09:17+03:00
New Revision: 0c184154969c020db416bd7066af80ffd2a27ac4
URL: https://github.com/llvm/llvm-project/commit/0c184154969c020db416bd7066af80ffd2a27ac4
DIFF: https://github.com/llvm/llvm-project/commit/0c184154969c020db416bd7066af80ffd2a27ac4.diff
LOG: zz
Added:
Modified:
llvm/include/llvm/IR/IntrinsicInst.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/IntrinsicInst.h b/llvm/include/llvm/IR/IntrinsicInst.h
index 6c825d380fc95..b688ece7067e2 100644
--- a/llvm/include/llvm/IR/IntrinsicInst.h
+++ b/llvm/include/llvm/IR/IntrinsicInst.h
@@ -458,6 +458,47 @@ class ConstrainedFPCmpIntrinsic : public ConstrainedFPIntrinsic {
}
};
+/// This class represents min/max intrinsics.
+class LimitingIntrinsic : public IntrinsicInst {
+public:
+ static bool classof(const IntrinsicInst *I) {
+ switch (I->getIntrinsicID()) {
+ case Intrinsic::umin:
+ case Intrinsic::umax:
+ case Intrinsic::smin:
+ case Intrinsic::smax:
+ return true;
+ default:
+ return false;
+ }
+ }
+ static bool classof(const Value *V) {
+ return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
+ }
+
+ Value *getLHS() const { return const_cast<Value *>(getArgOperand(0)); }
+ Value *getRHS() const { return const_cast<Value *>(getArgOperand(1)); }
+
+ /// Returns the comparison predicate underlying the intrinsic.
+ ICmpInst::Predicate getPredicate() const {
+ switch (getIntrinsicID()) {
+ case Intrinsic::umin:
+ return ICmpInst::Predicate::ICMP_ULT;
+ case Intrinsic::umax:
+ return ICmpInst::Predicate::ICMP_UGT;
+ case Intrinsic::smin:
+ return ICmpInst::Predicate::ICMP_SLT;
+ case Intrinsic::smax:
+ return ICmpInst::Predicate::ICMP_SGT;
+ default:
+ llvm_unreachable("Invalid intrinsic");
+ }
+ }
+
+ /// Whether the intrinsic is signed or unsigned.
+ bool isSigned() const { return ICmpInst::isSigned(getPredicate()); };
+};
+
/// This class represents an intrinsic that is based on a binary operation.
/// This includes op.with.overflow and saturating add/sub intrinsics.
class BinaryOpIntrinsic : public IntrinsicInst {
More information about the llvm-commits
mailing list