diff options
author | Andreas Krebbel <krebbel@linux.ibm.com> | 2021-09-22 09:32:21 +0200 |
---|---|---|
committer | Andreas Krebbel <krebbel@linux.ibm.com> | 2021-09-22 09:42:26 +0200 |
commit | a9b3c451be58f0fe660154323ace7ba72a4211ec (patch) | |
tree | 888969d30f85ca6c3f942026aa16093aa2116f3b /gcc | |
parent | c4432b2776aeeffee9125bf87ff937e4a8907bbd (diff) | |
download | gcc-a9b3c451be58f0fe660154323ace7ba72a4211ec.zip gcc-a9b3c451be58f0fe660154323ace7ba72a4211ec.tar.gz gcc-a9b3c451be58f0fe660154323ace7ba72a4211ec.tar.bz2 |
IBM Z: Fix PR102222
Avoid emitting a strict low part move if the insv target actually
affects the whole target reg.
gcc/ChangeLog:
PR target/102222
* config/s390/s390.c (s390_expand_insv): Emit a normal move if it
is actually a full copy of the source operand into the target.
Don't emit a strict low part move if source and target mode match.
gcc/testsuite/ChangeLog:
* gcc.target/s390/pr102222.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/s390/s390.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/s390/pr102222.c | 16 |
2 files changed, 26 insertions, 0 deletions
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 54dd633..e043854 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -6414,6 +6414,15 @@ s390_expand_insv (rtx dest, rtx op1, rtx op2, rtx src) if (bitsize + bitpos > GET_MODE_BITSIZE (mode)) return false; + /* Just a move. */ + if (bitpos == 0 + && bitsize == GET_MODE_BITSIZE (GET_MODE (src)) + && mode == GET_MODE (src)) + { + emit_move_insn (dest, src); + return true; + } + /* Generate INSERT IMMEDIATE (IILL et al). */ /* (set (ze (reg)) (const_int)). */ if (TARGET_ZARCH @@ -6510,6 +6519,7 @@ s390_expand_insv (rtx dest, rtx op1, rtx op2, rtx src) && (bitpos & 32) == ((bitpos + bitsize - 1) & 32) && MEM_P (src) && (mode == DImode || mode == SImode) + && mode != smode && register_operand (dest, mode)) { /* Emit a strict_low_part pattern if possible. */ diff --git a/gcc/testsuite/gcc.target/s390/pr102222.c b/gcc/testsuite/gcc.target/s390/pr102222.c new file mode 100644 index 0000000..47d075e --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/pr102222.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -m31 -mesa" } */ + +struct squashfs_reg_inode_header_1 read_inode_inode; + +int read_inode_val; + +struct squashfs_reg_inode_header_1 +{ + int file_size:32; +} __attribute__((packed)) read_inode (); + +void foo (void) +{ + read_inode_inode.file_size = read_inode_val; +} |