[llvm] [InstCombine] Improve select equiv fold for plain condition (PR #83405)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 7 08:00:57 PDT 2024


================
@@ -500,6 +500,44 @@ static bool isSelect01(const APInt &C1I, const APInt &C2I) {
   return C1I.isOne() || C1I.isAllOnes() || C2I.isOne() || C2I.isAllOnes();
 }
 
+/// Try to simplify a select instruction when the user of its select user
+/// indicates the condition.
+static bool simplifySeqSelectWithSameCond(SelectInst &SI,
+                                          const SimplifyQuery &SQ,
+                                          InstCombinerImpl &IC) {
+  Value *CondVal = SI.getCondition();
+  if (match(CondVal, m_ImmConstant()))
+    return false;
----------------
dtcxzyw wrote:

https://github.com/llvm/llvm-project/blob/a61252419779a6d4a5ebf71e7e2fc4adc75cfddd/llvm/lib/Analysis/InstructionSimplify.cpp#L4767-L4771

Can you provide a test to show that the early exit here is necessary?


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


More information about the llvm-commits mailing list