aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>2016-07-12 15:00:28 +0000
committerktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>2016-07-12 15:00:28 +0000
commitcd32d7475b83c730185d0a266838a60999515632 (patch)
tree277c9334e6c15f3d94d37021a3b0b7007827c8eb /gcc/expr.c
parent1138783ec9f31bdd09548e72296f804d6ad6cc5c (diff)
[expr.c] PR middle-end/71700: zero-extend sub-word value when widening constructor element
PR middle-end/71700 * expr.c (store_constructor): Mask sign-extended bits when widening sub-word constructor element at the start of a word. * gcc.c-torture/execute/pr71700.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@238248 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index fbc91ad667f..4073a989d96 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -6281,6 +6281,13 @@ store_constructor (tree exp, rtx target, int cleared, HOST_WIDE_INT size,
type = lang_hooks.types.type_for_mode
(word_mode, TYPE_UNSIGNED (type));
value = fold_convert (type, value);
+ /* Make sure the bits beyond the original bitsize are zero
+ so that we can correctly avoid extra zeroing stores in
+ later constructor elements. */
+ tree bitsize_mask
+ = wide_int_to_tree (type, wi::mask (bitsize, false,
+ BITS_PER_WORD));
+ value = fold_build2 (BIT_AND_EXPR, type, value, bitsize_mask);
}
if (BYTES_BIG_ENDIAN)