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.
This commit is contained in:
Andreas Krebbel 2021-09-22 09:32:21 +02:00
parent c4432b2776
commit a9b3c451be
2 changed files with 26 additions and 0 deletions

View File

@ -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. */

View File

@ -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;
}