[PATCH] D107148: [InstCombine] Fold two-value clamp patterns

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 25 06:19:09 PDT 2021


spatel added a comment.

Sorry for missing this review earlier.
I implemented the corresponding folds for intrinsics with:
https://reviews.llvm.org/rG025bb5290379

Can you confirm that the pattern matching and tests here correspond to those (replace the intrinsics with cmp+sel or vice-versa)?



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:3110
+             InnerFlavor == SelectPatternFlavor::SPF_SMAX &&
+             C2->getValue() == C1->getValue() + 1))
+          return SelectInst::Create(
----------------
RKSimon wrote:
> Can we use m_SMin etc. ? Ideally we'd have something that matches min/max intrinsics as well as select patterns.
`m_MaxOrMin()` will match either pattern (intrinsic or cmp+sel). We're starting from a select here, so I'm not sure if it's worth including tests with mismatched patterns (one of each).
Also see getInverseMinMaxFlavor() or getInverseMinMaxPred() in ValueTracking.h.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107148/new/

https://reviews.llvm.org/D107148



More information about the llvm-commits mailing list