[llvm] [LV] Add extra check for signed overflow for SDiv/SRem (PR #170818)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 3 06:07:35 PST 2026


================
@@ -1434,6 +1434,50 @@ static void simplifyRecipe(VPSingleDefRecipe *Def, VPTypeAnalysis &TypeInfo) {
     return;
   }
 
+  // Drop header mask if LHS/RHS range is safe.
+  // (sdiv lhs, (select header, rhs, 1)) -> (sdiv lhs, rhs)
+  // (srem lhs, (select header, rhs, 1)) -> (srem lhs, rhs)
+  VPValue *LHS, *WSel, *RHS, *Mask;
+  if (match(Def, m_CombineOr(m_VPWidenRecipe<Instruction::SDiv>(
----------------
fhahn wrote:

There should be no need to specifically look for widen recipes, can you just use m_Binary?

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


More information about the llvm-commits mailing list