]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
slsr: Move introduce_cast_before_cand to use gimple_convert
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Fri, 16 Jan 2026 22:48:48 +0000 (14:48 -0800)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Fri, 23 Jan 2026 16:02:17 +0000 (08:02 -0800)
This moves introduce_cast_before_cand to use gimple_convert
instead of manually creating the gimple assign. In theory
there could be a removal of one statement being created
but I have not looked to check that.

gcc/ChangeLog:

* gimple-ssa-strength-reduction.cc (introduce_cast_before_cand): Use
gimple_convert instead of manually creating the gimple_assign.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/gimple-ssa-strength-reduction.cc

index 3bb924fa54cdd8b18929e2462647b136efa6c4c3..abfc8e00d81df154c5b29f0defd9d10b441b8928 100644 (file)
@@ -3648,18 +3648,17 @@ static tree
 introduce_cast_before_cand (slsr_cand_t c, tree to_type, tree from_expr)
 {
   tree cast_lhs;
-  gassign *cast_stmt;
   gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
 
-  cast_lhs = make_temp_ssa_name (to_type, NULL, "slsr");
-  cast_stmt = gimple_build_assign (cast_lhs, NOP_EXPR, from_expr);
-  gimple_set_location (cast_stmt, gimple_location (c->cand_stmt));
-  gsi_insert_before (&gsi, cast_stmt, GSI_SAME_STMT);
+  cast_lhs = gimple_convert (&gsi, true, GSI_SAME_STMT,
+                            gimple_location (c->cand_stmt),
+                            to_type, from_expr);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
-      fputs ("  Inserting: ", dump_file);
-      print_gimple_stmt (dump_file, cast_stmt, 0);
+      fputs ("  Inserting(cast): ", dump_file);
+      print_generic_expr (dump_file, cast_lhs);
+      fprintf (dump_file, "\n");
     }
 
   return cast_lhs;