[gcc r15-1305] expand: constify sepops operand to expand_expr_real_2 and expand_widen_pattern_expr [PR113212]
Andrew Pinski
pinskia@gcc.gnu.org
Fri Jun 14 03:11:05 GMT 2024
https://gcc.gnu.org/g:d8a6de9e2b850b71712e89e8e6026e4ae6284766
commit r15-1305-gd8a6de9e2b850b71712e89e8e6026e4ae6284766
Author: Andrew Pinski <quic_apinski@quicinc.com>
Date: Thu Jun 13 13:07:10 2024 -0700
expand: constify sepops operand to expand_expr_real_2 and expand_widen_pattern_expr [PR113212]
While working on an expand patch back in January I noticed that
the first argument (of sepops type) of expand_expr_real_2 could be
constified as it was not to be touched by the function (nor should it be).
There is code in internal-fn.cc that depends on expand_expr_real_2 not touching
the ops argument so constification makes this more obvious.
Bootstrapped and tested on x86_64-linux-gnu with no regressions.
gcc/ChangeLog:
PR middle-end/113212
* expr.h (const_seqpops): New typedef.
(expand_expr_real_2): Constify the first argument.
* optabs.cc (expand_widen_pattern_expr): Likewise.
* optabs.h (expand_widen_pattern_expr): Likewise.
* expr.cc (expand_expr_real_2): Likewise
(do_store_flag): Likewise. Remove incorrect store to ops->code.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Diff:
---
gcc/expr.cc | 8 ++++----
gcc/expr.h | 4 +++-
gcc/optabs.cc | 2 +-
gcc/optabs.h | 2 +-
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/gcc/expr.cc b/gcc/expr.cc
index 04bad5e1425d..9cecc1758f5c 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -94,7 +94,7 @@ static unsigned HOST_WIDE_INT highest_pow2_factor_for_target (const_tree, const_
static bool is_aligning_offset (const_tree, const_tree);
static rtx reduce_to_bit_field_precision (rtx, rtx, tree);
-static rtx do_store_flag (sepops, rtx, machine_mode);
+static rtx do_store_flag (const_sepops, rtx, machine_mode);
#ifdef PUSH_ROUNDING
static void emit_single_push_insn (machine_mode, rtx, tree);
#endif
@@ -9643,7 +9643,7 @@ expand_expr_divmod (tree_code code, machine_mode mode, tree treeop0,
}
rtx
-expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
+expand_expr_real_2 (const_sepops ops, rtx target, machine_mode tmode,
enum expand_modifier modifier)
{
rtx op0, op1, op2, temp;
@@ -13504,7 +13504,7 @@ expand_single_bit_test (location_t loc, enum tree_code code,
set/jump/set sequence. */
static rtx
-do_store_flag (sepops ops, rtx target, machine_mode mode)
+do_store_flag (const_sepops ops, rtx target, machine_mode mode)
{
enum rtx_code code;
tree arg0, arg1, type;
@@ -13566,7 +13566,7 @@ do_store_flag (sepops ops, rtx target, machine_mode mode)
if (new_code != ops->code)
{
struct separate_ops nops = *ops;
- nops.code = ops->code = new_code;
+ nops.code = new_code;
nops.op0 = arg0;
nops.op1 = arg1;
nops.type = TREE_TYPE (arg0);
diff --git a/gcc/expr.h b/gcc/expr.h
index 751815841083..533ae0af3871 100644
--- a/gcc/expr.h
+++ b/gcc/expr.h
@@ -53,6 +53,8 @@ typedef struct separate_ops
tree type;
tree op0, op1, op2;
} *sepops;
+
+typedef const struct separate_ops *const_sepops;
/* This is run during target initialization to set up which modes can be
used directly in memory and to initialize the block move optab. */
@@ -305,7 +307,7 @@ extern rtx expand_expr_real (tree, rtx, machine_mode,
enum expand_modifier, rtx *, bool);
extern rtx expand_expr_real_1 (tree, rtx, machine_mode,
enum expand_modifier, rtx *, bool);
-extern rtx expand_expr_real_2 (sepops, rtx, machine_mode,
+extern rtx expand_expr_real_2 (const_sepops, rtx, machine_mode,
enum expand_modifier);
extern rtx expand_expr_real_gassign (gassign *, rtx, machine_mode,
enum expand_modifier modifier,
diff --git a/gcc/optabs.cc b/gcc/optabs.cc
index 78cd9ef34488..c54d275b8b7a 100644
--- a/gcc/optabs.cc
+++ b/gcc/optabs.cc
@@ -253,7 +253,7 @@ widen_operand (rtx op, machine_mode mode, machine_mode oldmode,
type-promotion (vec-unpack) 1 oprnd0 - - */
rtx
-expand_widen_pattern_expr (sepops ops, rtx op0, rtx op1, rtx wide_op,
+expand_widen_pattern_expr (const_sepops ops, rtx op0, rtx op1, rtx wide_op,
rtx target, int unsignedp)
{
class expand_operand eops[4];
diff --git a/gcc/optabs.h b/gcc/optabs.h
index c0b8df5268f6..301847e2186d 100644
--- a/gcc/optabs.h
+++ b/gcc/optabs.h
@@ -182,7 +182,7 @@ enum optab_methods
OPTAB_MUST_WIDEN
};
-extern rtx expand_widen_pattern_expr (struct separate_ops *, rtx , rtx , rtx,
+extern rtx expand_widen_pattern_expr (const struct separate_ops *, rtx , rtx , rtx,
rtx, int);
extern rtx expand_ternary_op (machine_mode mode, optab ternary_optab,
rtx op0, rtx op1, rtx op2, rtx target,
More information about the Gcc-cvs
mailing list