https://gcc.gnu.org/g:a426e0a8c5ee9cdcf842ea44dc396069e890a4ca

commit r17-4214-ga426e0a8c5ee9cdcf842ea44dc396069e890a4ca
Author: Richard Biener <[email protected]>
Date:   Mon Sep 14 09:28:39 2026 +0200

    tree-optimization/127363 - fix bogus vector PAREN_EXPR code generation
    
    We are simply dropping PAREN_EXPRs which is of course incorrect.
    
            PR tree-optimization/127363
            * tree-vect-stmts.cc (vectorizable_assignment): Properly
            code-generate PAREN_EXPRs.
    
            * gcc.dg/vect/vect-pr127363.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/vect/vect-pr127363.c | 11 +++++++++++
 gcc/tree-vect-stmts.cc                    | 14 ++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr127363.c 
b/gcc/testsuite/gcc.dg/vect/vect-pr127363.c
new file mode 100644
index 000000000000..1cb6113991ea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-pr127363.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ffast-math" } */
+
+void round_values(float* values)
+{
+  const float big = 0x1p24f;
+  for (int i = 0; i < 8; ++i)
+    values[i] = __builtin_assoc_barrier(values[i] + big) - big;
+}
+
+/* { dg-final { scan-tree-dump "\\\(\\\(vect__\[0-9._\]*\\\)\\\)" "vect" { 
target vect_float } } } */
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 65d82d51310b..51d71270d1b6 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -6086,10 +6086,16 @@ vectorizable_assignment (vec_info *vinfo,
   /* Arguments are ready. create the new vector stmt.  */
   FOR_EACH_VEC_ELT (vec_oprnds, i, vop)
     {
-      if (CONVERT_EXPR_CODE_P (code)
-         || code == VIEW_CONVERT_EXPR)
-       vop = build1 (VIEW_CONVERT_EXPR, vectype, vop);
-      gassign *new_stmt = gimple_build_assign (vec_dest, vop);
+      gassign *new_stmt;
+      if (code == PAREN_EXPR)
+       new_stmt = gimple_build_assign (vec_dest, PAREN_EXPR, vop);
+      else
+       {
+         if (CONVERT_EXPR_CODE_P (code)
+             || code == VIEW_CONVERT_EXPR)
+           vop = build1 (VIEW_CONVERT_EXPR, vectype, vop);
+         new_stmt = gimple_build_assign (vec_dest, vop);
+       }
       new_temp = make_ssa_name (vec_dest, new_stmt);
       gimple_assign_set_lhs (new_stmt, new_temp);
       vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi);

Reply via email to