[llvm] [ValueTracking] Analyze `Select` in `isKnownNonEqual`. (PR #68427)
Mikhail Gudim via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 8 10:10:35 PDT 2023
================
@@ -3112,6 +3112,39 @@ static bool isNonEqualPHIs(const PHINode *PN1, const PHINode *PN2,
return true;
}
+static bool isNonEqualSelect(const Value *V1, const Value *V2, unsigned Depth,
+ const SimplifyQuery &Q) {
+ const SelectInst *SI1 = dyn_cast<SelectInst>(V1);
+ if (!SI1)
+ return false;
+
+ if (const SelectInst *SI2 = dyn_cast<SelectInst>(V2)) {
+ const Value *TVal1 = nullptr;
+ const Value *TVal2 = nullptr;
+ const Value *FVal1 = nullptr;
+ const Value *FVal2 = nullptr;
+ const Value *Cond1 = SI1->getCondition();
+ const Value *Cond2 = SI2->getCondition();
+ if (Cond1 == Cond2) {
+ TVal1 = SI1->getTrueValue();
+ TVal2 = SI2->getTrueValue();
+ FVal1 = SI1->getFalseValue();
+ FVal2 = SI2->getFalseValue();
+ }
+ if (match(Cond1, m_Not(m_Specific(Cond2)))) {
----------------
mgudim wrote:
Did I understand correctly: you mean we could have something like `%Cond1 = icmp sle %x, 10` and `%Cond2 = icmp sgt %x, 10`, so no explicit `xor, -1` between the two, but two are actually always opposite. Thanks, very good point!
Let me see if there is some API for that.
https://github.com/llvm/llvm-project/pull/68427
More information about the llvm-commits
mailing list