[llvm] [GVN] Support rnflow pattern matching and transform (PR #162259)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 8 00:04:12 PST 2025


================
@@ -3330,6 +3334,128 @@ void GVNPass::assignValNumForDeadCode() {
   }
 }
 
+bool GVNPass::transformMinFindingSelectPattern(
+    Loop *L, Type *LoadType, BasicBlock *Preheader, BasicBlock *BB, Value *LHS,
+    Value *RHS, CmpInst *Comparison, SelectInst *Select, Value *BasePtr,
+    Value *IndexVal, Value *OffsetVal) {
+  // Hoist the chain of operations for the second load to preheader.
+  // %min.idx.ext = sext i32 %min.idx to i64
+  // %ptr.float.min = getelementptr float, ptr %0, i64 %min.idx.ext
+  // %ptr.second.load = getelementptr i8, ptr %ptr.float.min, i64 -4
+  // %val.current.min = load float, ptr %ptr.second.load, align 4
----------------
nikic wrote:

It would be great if there was a comment with the full before + after pattern before the implementation code.

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


More information about the llvm-commits mailing list