[llvm] [VPlan] Fold NOT into predicate of wide compares. (PR #129430)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 5 08:37:55 PST 2025


================
@@ -972,8 +972,25 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
   if (match(&R, m_c_Mul(m_VPValue(A), m_SpecificInt(1))))
     return R.getVPSingleValue()->replaceAllUsesWith(A);
 
-  if (match(&R, m_Not(m_Not(m_VPValue(A)))))
-    return R.getVPSingleValue()->replaceAllUsesWith(A);
+  if (match(&R, m_Not(m_VPValue(A)))) {
+    if (match(A, m_Not(m_VPValue(A))))
+      return R.getVPSingleValue()->replaceAllUsesWith(A);
+
+    // Try to fold Not into compares by adjusting the predicate in-place.
+    if (isa<VPWidenRecipe>(A) && A->getNumUsers() == 1) {
+      auto *WideCmp = cast<VPWidenRecipe>(A);
+      if (WideCmp->getOpcode() == Instruction::ICmp ||
+          WideCmp->getOpcode() == Instruction::FCmp) {
----------------
david-arm wrote:

I've forgotten the rules somewhat regarding what's permitted with strict FP, but are there any issues with not(fcmp pred1) being transformed to fcmp pred2? For example, if an input is NaN?

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


More information about the llvm-commits mailing list