https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123979

            Bug ID: 123979
           Summary: complex lowering should update vop manually
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: internal-improvement
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

As mentioned in
https://gcc.gnu.org/pipermail/gcc-patches/2026-February/707575.html.

Complex lowering should update the vop for the new load/stores instead of
relying on the renamer.

The first thing is extract_component needs to be split into 2 pieces really.
!gimple_p and gimple_p case.

The !gimple_p case should only be handling COMPLEX_CST/SSA_NAME .

With that in mind, this code:
```

        else if (is_gimple_assign (stmt)
                 && (gimple_assign_rhs_code (stmt) == REALPART_EXPR
                     || gimple_assign_rhs_code (stmt) == IMAGPART_EXPR)
                 && TREE_CODE (lhs) == SSA_NAME)
          {
            rhs = gimple_assign_rhs1 (stmt);
            rhs = extract_component (gsi, TREE_OPERAND (rhs, 0),
                                     gimple_assign_rhs_code (stmt)
                                       == IMAGPART_EXPR,
                                     false);
            gimple_assign_set_rhs_from_tree (gsi, rhs);
            stmt = gsi_stmt (*gsi);
            update_stmt (stmt);
          }
```
Should be restricted to `TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME` as it
is just creating a copy of the rhs for no reason.
Note I am not even sure `TREE_CODE (lhs) == SSA_NAME` will never be false here
either.

Reply via email to