[llvm] [SimplifyCFG] Handle that first matched eq cond in if chain can be Extra condition. (PR #154007)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 17 07:20:28 PDT 2025


================
@@ -564,9 +564,19 @@ struct ConstantComparesGatherer {
   /// Number of comparisons matched in the and/or chain
   unsigned UsedICmps = 0;
 
+  // Used to check if the first matched CompValue shall be the Extra check.
+  bool IgnoreFirstMatch = false;
+
   /// Construct and compute the result for the comparison instruction Cond
   ConstantComparesGatherer(Instruction *Cond, const DataLayout &DL) : DL(DL) {
     gather(Cond);
+    if (CompValue)
+      return;
+    Extra = nullptr;
+    Vals.clear();
+    UsedICmps = 0;
+    IgnoreFirstMatch = true;
+    gather(Cond);
----------------
dtcxzyw wrote:

I don't have a better idea for now.

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


More information about the llvm-commits mailing list