aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-05-21 05:16:20 -0700
committerH.J. Lu <hjl.tools@gmail.com>2021-05-21 07:27:37 -0700
commit53fb833d635da04f5b44af16bcea1082e7b59e75 (patch)
tree6166e9128634ef8eb9e93e10f6e77b405d0c2921 /gcc/expr.c
parent5d42db533324e80a7382b20b94cace5b202d41ea (diff)
downloadgcc-53fb833d635da04f5b44af16bcea1082e7b59e75.zip
gcc-53fb833d635da04f5b44af16bcea1082e7b59e75.tar.gz
gcc-53fb833d635da04f5b44af16bcea1082e7b59e75.tar.bz2
Elide expand_constructor if move by pieces is preferred
Elide expand_constructor when the constructor is static storage and not mostly zeros and we can move it by pieces prefer to do so since that's usually more efficient than performing a series of stores from immediates. 2021-05-21 Richard Biener <rguenther@suse.de> H.J. Lu <hjl.tools@gmail.com> gcc/ PR middle-end/90773 * expr.c (expand_constructor): Elide expand_constructor if move by pieces is preferred. gcc/testsuite/ * gcc.target/i386/pr90773-24.c: New test. * gcc.target/i386/pr90773-25.c: Likewise.
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index d09ee42..ba61eb9 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -8523,6 +8523,19 @@ expand_constructor (tree exp, rtx target, enum expand_modifier modifier,
return constructor;
}
+ /* If the CTOR is available in static storage and not mostly
+ zeros and we can move it by pieces prefer to do so since
+ that's usually more efficient than performing a series of
+ stores from immediates. */
+ if (avoid_temp_mem
+ && TREE_STATIC (exp)
+ && TREE_CONSTANT (exp)
+ && tree_fits_uhwi_p (TYPE_SIZE_UNIT (type))
+ && can_move_by_pieces (tree_to_uhwi (TYPE_SIZE_UNIT (type)),
+ TYPE_ALIGN (type))
+ && ! mostly_zeros_p (exp))
+ return NULL_RTX;
+
/* Handle calls that pass values in multiple non-contiguous
locations. The Irix 6 ABI has examples of this. */
if (target == 0 || ! safe_from_p (target, exp, 1)