[llvm] [ConstraintElimination] Add support for UCMP/SCMP intrinsics (PR #97974)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 7 19:52:40 PDT 2024


================
@@ -1736,6 +1765,11 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI,
         Changed |= Simplified;
       } else if (auto *MinMax = dyn_cast<MinMaxIntrinsic>(Inst)) {
         Changed |= checkAndReplaceMinMax(MinMax, Info, ToRemove);
+      } else if (auto *CmpIntrinsic = dyn_cast<IntrinsicInst>(Inst);
+                 CmpIntrinsic &&
+                 (CmpIntrinsic->getIntrinsicID() == Intrinsic::scmp ||
+                  CmpIntrinsic->getIntrinsicID() == Intrinsic::ucmp)) {
----------------
dtcxzyw wrote:

Do we need a helper class like `CmpIntrinsic`?
```
class CmpIntrinsic : public IntrinsicInst {
public:
  static bool classof(const IntrinsicInst *I) {...}
  Value *getLHS() const {...}
  Value *getRHS() const {...}
  bool isSigned() {...}
  static bool isSigned(Intrinsic::ID ID) {...}
  ICmpInst::Predicate getEqPredicate() {...}
  static ICmpInst::Predicate getEqPredicate(Intrinsic::ID ID) {...}
  ICmpInst::Predicate getLtPredicate() {...}
  static ICmpInst::Predicate getLtPredicate(Intrinsic::ID ID) {...}
  ICmpInst::Predicate getGtPredicate() {...}
  static ICmpInst::Predicate getGtPredicate(Intrinsic::ID ID) {...}
};
```

https://github.com/llvm/llvm-project/pull/97974


More information about the llvm-commits mailing list