summaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 76441c746bc..a0ce0db9766 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -5295,3 +5295,20 @@ rewrite_to_defined_overflow (gimple stmt)
return stmts;
}
+
+/* Return OP converted to TYPE by emitting a conversion statement on SEQ
+ if required using location LOC. Note that OP will be returned
+ unmodified if GIMPLE does not require an explicit conversion between
+ its type and TYPE. */
+
+tree
+gimple_convert (gimple_seq *seq, location_t loc, tree type, tree op)
+{
+ if (useless_type_conversion_p (type, TREE_TYPE (op)))
+ return op;
+ op = fold_convert_loc (loc, type, op);
+ gimple_seq stmts = NULL;
+ op = force_gimple_operand (op, &stmts, true, NULL_TREE);
+ gimple_seq_add_seq_without_update (seq, stmts);
+ return op;
+}