https://gcc.gnu.org/g:2f817b3ea9e9ed00c7f158bb43e6c234e5962bbd

commit r17-6594-g2f817b3ea9e9ed00c7f158bb43e6c234e5962bbd
Author: Richard Biener <[email protected]>
Date:   Mon Nov 23 11:10:24 2026 +0100

    tree-optimization/128946 - costing of PAREN_EXPR
    
    The vectorizer costs PAREN_EXPR as scalar/vector_stmt which gives
    the vector side an unwarranted advantage.  Count it as nop.
    
            PR tree-optimization/128946
            * tree-vect-stmts.cc (vect_nop_conversion_p): PAREN_EXPR
            is also a nop.
    
            * gfortran.dg/vect/cost-model-pr128946.f90: New testcase.

Diff:
---
 gcc/testsuite/gfortran.dg/vect/cost-model-pr128946.f90 | 10 ++++++++++
 gcc/tree-vect-stmts.cc                                 |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gfortran.dg/vect/cost-model-pr128946.f90 
b/gcc/testsuite/gfortran.dg/vect/cost-model-pr128946.f90
new file mode 100644
index 000000000000..0e2aabd72d21
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/vect/cost-model-pr128946.f90
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! { dg-additional-options "-fvect-cost-model=dynamic -fdump-tree-slp2-details" 
}
+
+real(8) function radd_v5 (a,b,c,d) result(res)
+  real(8), value :: a, b, c, d
+  real(8) :: tmp
+  res = (a + b) + (c + d)
+end function radd_v5
+
+! { dg-final { scan-tree-dump-not "optimized: basic block part vectorized" 
"slp2" } }
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 9e1238e63ca5..a884c05fa196 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -6040,7 +6040,7 @@ vect_nop_conversion_p (stmt_vec_info stmt_info)
   tree_code code = gimple_assign_rhs_code (stmt);
   tree rhs = gimple_assign_rhs1 (stmt);
 
-  if (code == SSA_NAME || code == VIEW_CONVERT_EXPR)
+  if (code == SSA_NAME || code == VIEW_CONVERT_EXPR || code == PAREN_EXPR)
     return true;
 
   if (CONVERT_EXPR_CODE_P (code))

Reply via email to