[llvm] [InstCombine] Fold extended add/sub of the same type (PR #185259)

via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 8 06:59:15 PDT 2026


================
@@ -1081,6 +1081,28 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
 
   Value *A, *B;
   Constant *C;
+  ConstantInt *CInt;
+
+  if (match(Src, m_UMin(m_Add(m_ZExt(m_Value(A)), m_ZExt(m_Value(B))),
----------------
suoyuan666 wrote:

you are right. but it seems that I need use `m_OneUse` to every operations, not just `m_UMin` and `m_Add` ?

this optimization will delete some virtual register, so I should ensure that each virtual register has only one user.

anyway, I will write more test case to test it.

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


More information about the llvm-commits mailing list