Bug 122989 - some force_gimple_operand_gsi in tree-strlen.cc should be replaced by gimple_build/gimple_convert
Summary: some force_gimple_operand_gsi in tree-strlen.cc should be replaced by gimple_...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 16.0
: P3 enhancement
Target Milestone: 17.0
Assignee: Avinal Kumar
URL:
Keywords: easyhack, internal-improvement
Depends on:
Blocks:
 
Reported: 2025-12-03 18:19 UTC by Drea Pinski
Modified: 2026-04-25 03:16 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2025-12-04 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Drea Pinski 2025-12-03 18:19:43 UTC
```
          if (!ptrofftype_p (TREE_TYPE (lhs)))
            {
              lhs = convert_to_ptrofftype (lhs);
              lhs = force_gimple_operand_gsi (&gsi, lhs, true, NULL_TREE,
                                              true, GSI_SAME_STMT);
            }
          lenstmt = gimple_build_assign
                        (make_ssa_name (TREE_TYPE (gimple_call_arg (stmt, 0))),
                         POINTER_PLUS_EXPR,tem, lhs);
          gsi_insert_before (&gsi, lenstmt, GSI_SAME_STMT);
```
This could be using gimple_convert_to_ptrofftype and then gimple_build instead of convert_to_ptrofftype/force_gimple_operand_gsi /gimple_build_assign/gsi_insert_before .
Comment 1 Richard Biener 2025-12-04 09:04:16 UTC
Confirmed.
Comment 2 Avinal Kumar 2026-04-20 08:56:11 UTC
Hello I got this issue link from GNU Tools weekly and would like to work on it.
Comment 3 GCC Commits 2026-04-25 03:12:29 UTC
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:2985e0bd9b2aee03a932e5ab406523a95c04de5f

commit r17-82-g2985e0bd9b2aee03a932e5ab406523a95c04de5f
Author: Avinal Kumar <avinal.xlvii@gmail.com>
Date:   Thu Apr 23 23:43:23 2026 +0530

    tree-ssa-strlen: Use gimple_build/gimple_convert_to_ptrofftype [PR122989]
    
    Replace convert_to_ptrofftype, force_gimple_operand_gsi,
    gimple_build_assign, and gsi_insert_before with
    gimple_convert_to_ptrofftype and gimple_build.
    
    gcc/ChangeLog:
    
            PR tree-optimization/122989
            * tree-ssa-strlen.cc (get_string_length): Use
            gimple_convert_to_ptrofftype and gimple_build instead of
            convert_to_ptrofftype/force_gimple_operand_gsi/gimple_build_assign.
    
    Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
Comment 4 Drea Pinski 2026-04-25 03:16:16 UTC
Fixed. Thanks again for working on this.