[llvm] [VectorCombine] fold fptoui(fdiv(uitofp(x),uitofp(y))) into udiv(x,y) (PR #214844)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 02:17:18 PDT 2026


================
@@ -2332,6 +2334,94 @@ bool VectorCombine::scalarizeExtExtract(Instruction &I) {
   return true;
 }
 
+/// Try to fold fptoui(fdiv(x,y)) to udiv(x,y), where x & y are either uitofp
+/// instructions or fp-constants that exactly represent integers.
+bool VectorCombine::foldFDivToUDiv(Instruction &I) {
+  const DataLayout &DL = I.getDataLayout();
+  Value *X, *Y;
+  if (!match(&I, m_FPToUI(m_OneUse(m_FDiv(m_Value(X), m_Value(Y))))))
+    return false;
+
+  Type *IntTy = I.getType();
+
+  auto MatchConstOrInst = [&](Value *V, Value *&Src) -> bool {
----------------
RKSimon wrote:

It'd be much cleaner to return Value* /  nullptr on failure

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


More information about the llvm-commits mailing list