diff options
author | Sanjay Patel <spatel@rotateright.com> | 2021-08-10 10:57:25 -0400 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2021-08-10 10:57:25 -0400 |
commit | e260e10c4a21784c146c94a2a14b7e78b09a9cf7 (patch) | |
tree | c43e7a9f66c934aa5b5ac52dcec73eee1cf43956 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 188832f4191c5ef165eb213107ebff371cb57ecd (diff) | |
download | llvm-e260e10c4a21784c146c94a2a14b7e78b09a9cf7.zip llvm-e260e10c4a21784c146c94a2a14b7e78b09a9cf7.tar.gz llvm-e260e10c4a21784c146c94a2a14b7e78b09a9cf7.tar.bz2 |
[InstSimplify] fold min/max with limit constant
This is already done within InstCombine:
https://alive2.llvm.org/ce/z/MiGE22
...but leaving it out of analysis makes it
harder to avoid infinite loops there.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index b146f07..1e63fc0 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -6253,6 +6253,16 @@ CmpInst::Predicate llvm::getInverseMinMaxPred(SelectPatternFlavor SPF) { return getMinMaxPred(getInverseMinMaxFlavor(SPF)); } +APInt llvm::getMinMaxLimit(SelectPatternFlavor SPF, unsigned BitWidth) { + switch (SPF) { + case SPF_SMAX: return APInt::getSignedMaxValue(BitWidth); + case SPF_SMIN: return APInt::getSignedMinValue(BitWidth); + case SPF_UMAX: return APInt::getMaxValue(BitWidth); + case SPF_UMIN: return APInt::getMinValue(BitWidth); + default: llvm_unreachable("Unexpected flavor"); + } +} + std::pair<Intrinsic::ID, bool> llvm::canConvertToMinOrMaxIntrinsic(ArrayRef<Value *> VL) { // Check if VL contains select instructions that can be folded into a min/max |