diff mbox series

[committed] i386: Use plus_constant instead of gen_rtx_PLUS

Message ID CAFULd4Z+OhrcOJ19=-ra8LatpKn+CGCw4tw1ZfiFFx0jiQa26Q@mail.gmail.com
State New
Headers show
Series [committed] i386: Use plus_constant instead of gen_rtx_PLUS | expand

Commit Message

Uros Bizjak May 3, 2020, 6:55 p.m. UTC
Replace gen_rtx_PLUS with a GEN_INT with plus_constant.

2020-05-03  UroŇ° Bizjak  <ubizjak@gmail.com>

    * config/i386/i386-expand.c (ix86_expand_int_movcc):
    Use plus_constant instead of gen_rtx_PLUS with GEN_INT.
    (emit_memmov): Ditto.
    (emit_memset): Ditto.
    (ix86_expand_strlensi_unroll_1): Ditto.
    (release_scratch_register_on_entry): Ditto.
    (gen_frame_set): Ditto.
    (ix86_emit_restore_reg_using_pop): Ditto.
    (ix86_emit_outlined_ms2sysv_restore): Ditto.
    (ix86_expand_epilogue): Ditto.
    (ix86_expand_split_stack_prologue): Ditto.
    * config/i386/i386.md (push immediate splitter): Ditto.
    (strmov): Ditto.
    (strset): Ditto.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline.

Uros.
diff mbox series

Patch

diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
index 48f00c5fcfc..26531585c5f 100644
--- a/gcc/config/i386/i386-expand.c
+++ b/gcc/config/i386/i386-expand.c
@@ -3170,7 +3170,7 @@  ix86_expand_int_movcc (rtx operands[])
 	    }
 	  if (cf != 0)
 	    {
-	      tmp = gen_rtx_PLUS (mode, tmp, GEN_INT (cf));
+	      tmp = plus_constant (mode, tmp, cf);
 	      nops++;
 	    }
 	  if (!rtx_equal_p (tmp, out))
@@ -5986,7 +5986,7 @@  static rtx
 emit_memmov (rtx destmem, rtx *srcmem, rtx destptr, rtx srcptr,
 	     HOST_WIDE_INT size_to_move)
 {
-  rtx dst = destmem, src = *srcmem, adjust, tempreg;
+  rtx dst = destmem, src = *srcmem, tempreg;
   enum insn_code code;
   machine_mode move_mode;
   int piece_size, i;
@@ -6022,7 +6022,7 @@  emit_memmov (rtx destmem, rtx *srcmem, rtx destptr, rtx srcptr,
 
   /* Emit moves.  We'll need SIZE_TO_MOVE/PIECE_SIZES moves.  */
   gcc_assert (size_to_move % piece_size == 0);
-  adjust = GEN_INT (piece_size);
+
   for (i = 0; i < size_to_move; i += piece_size)
     {
       /* We move from memory to memory, so we'll need to do it via
@@ -6032,9 +6032,9 @@  emit_memmov (rtx destmem, rtx *srcmem, rtx destptr, rtx srcptr,
       emit_insn (GEN_FCN (code) (dst, tempreg));
 
       emit_move_insn (destptr,
-		      gen_rtx_PLUS (Pmode, copy_rtx (destptr), adjust));
+		      plus_constant (Pmode, copy_rtx (destptr), piece_size));
       emit_move_insn (srcptr,
-		      gen_rtx_PLUS (Pmode, copy_rtx (srcptr), adjust));
+		      plus_constant (Pmode, copy_rtx (srcptr), piece_size));
 
       dst = adjust_automodify_address_nv (dst, move_mode, destptr,
 					  piece_size);
@@ -6191,7 +6191,7 @@  static rtx
 emit_memset (rtx destmem, rtx destptr, rtx promoted_val,
 	     HOST_WIDE_INT size_to_move)
 {
-  rtx dst = destmem, adjust;
+  rtx dst = destmem;
   enum insn_code code;
   machine_mode move_mode;
   int piece_size, i;
@@ -6216,7 +6216,7 @@  emit_memset (rtx destmem, rtx destptr, rtx promoted_val,
 
   /* Emit moves.  We'll need SIZE_TO_MOVE/PIECE_SIZES moves.  */
   gcc_assert (size_to_move % piece_size == 0);
-  adjust = GEN_INT (piece_size);
+
   for (i = 0; i < size_to_move; i += piece_size)
     {
       if (piece_size <= GET_MODE_SIZE (word_mode))
@@ -6230,7 +6230,7 @@  emit_memset (rtx destmem, rtx destptr, rtx promoted_val,
       emit_insn (GEN_FCN (code) (dst, promoted_val));
 
       emit_move_insn (destptr,
-		      gen_rtx_PLUS (Pmode, copy_rtx (destptr), adjust));
+		      plus_constant (Pmode, copy_rtx (destptr), piece_size));
 
       dst = adjust_automodify_address_nv (dst, move_mode, destptr,
 					  piece_size);
@@ -7783,7 +7783,7 @@  ix86_expand_strlensi_unroll_1 (rtx out, rtx src, rtx align_rtx)
 						     reg,
 						     tmpreg)));
        /* Emit lea manually to avoid clobbering of flags.  */
-       emit_insn (gen_rtx_SET (reg2, gen_rtx_PLUS (Pmode, out, const2_rtx)));
+       emit_insn (gen_rtx_SET (reg2, plus_constant (Pmode, out, 2)));
 
        tmp = gen_rtx_REG (CCNOmode, FLAGS_REG);
        tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 1a9823ec844..458fafb3cc9 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -7103,14 +7103,14 @@  release_scratch_register_on_entry (struct scratch_reg *sr, HOST_WIDE_INT offset,
 
 	  /* The RX FRAME_RELATED_P mechanism doesn't know about pop.  */
 	  RTX_FRAME_RELATED_P (insn) = 1;
-	  x = gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (UNITS_PER_WORD));
+	  x = plus_constant (Pmode, stack_pointer_rtx, UNITS_PER_WORD);
 	  x = gen_rtx_SET (stack_pointer_rtx, x);
 	  add_reg_note (insn, REG_FRAME_RELATED_EXPR, x);
 	  m->fs.sp_offset -= UNITS_PER_WORD;
 	}
       else
 	{
-	  rtx x = gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (offset));
+	  rtx x = plus_constant (Pmode, stack_pointer_rtx, offset);
 	  x = gen_rtx_SET (sr->reg, gen_rtx_MEM (word_mode, x));
 	  emit_insn (x);
 	}
@@ -7897,7 +7897,7 @@  gen_frame_set (rtx reg, rtx frame_reg, int offset, bool store)
   rtx addr, mem;
 
   if (offset)
-    addr = gen_rtx_PLUS (Pmode, frame_reg, GEN_INT (offset));
+    addr = plus_constant (Pmode, frame_reg, offset);
   mem = gen_frame_mem (GET_MODE (reg), offset ? addr : frame_reg);
   return gen_rtx_SET (store ? mem : reg, store ? reg : mem);
 }
@@ -8593,8 +8593,8 @@  ix86_emit_restore_reg_using_pop (rtx reg)
 	  m->fs.cfa_offset -= UNITS_PER_WORD;
 
 	  add_reg_note (insn, REG_CFA_DEF_CFA,
-			gen_rtx_PLUS (Pmode, stack_pointer_rtx,
-				      GEN_INT (m->fs.cfa_offset)));
+			plus_constant (Pmode, stack_pointer_rtx,
+				       m->fs.cfa_offset));
 	  RTX_FRAME_RELATED_P (insn) = 1;
 	}
     }
@@ -8778,7 +8778,7 @@  ix86_emit_outlined_ms2sysv_restore (const struct ix86_frame &frame,
 	  gcc_assert (m->fs.fp_valid);
 	  gcc_assert (m->fs.cfa_reg == hard_frame_pointer_rtx);
 
-	  tmp = gen_rtx_PLUS (DImode, rbp, GEN_INT (8));
+	  tmp = plus_constant (DImode, rbp, 8);
 	  RTVEC_ELT (v, vi++) = gen_rtx_SET (stack_pointer_rtx, tmp);
 	  RTVEC_ELT (v, vi++) = gen_rtx_SET (rbp, gen_rtx_MEM (DImode, rbp));
 	  tmp = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode));
@@ -8792,7 +8792,7 @@  ix86_emit_outlined_ms2sysv_restore (const struct ix86_frame &frame,
 	  gcc_assert (m->fs.sp_valid);
 
 	  r10 = gen_rtx_REG (DImode, R10_REG);
-	  tmp = gen_rtx_PLUS (Pmode, rsi, GEN_INT (stub_ptr_offset));
+	  tmp = plus_constant (Pmode, rsi, stub_ptr_offset);
 	  emit_insn (gen_rtx_SET (r10, tmp));
 
 	  RTVEC_ELT (v, vi++) = gen_rtx_SET (stack_pointer_rtx, r10);
@@ -9189,17 +9189,16 @@  ix86_expand_epilogue (int style)
 
       insn = emit_insn (gen_rtx_SET
 			(stack_pointer_rtx,
-			 gen_rtx_PLUS (Pmode,
-				       crtl->drap_reg,
-				       GEN_INT (-param_ptr_offset))));
+			 plus_constant (Pmode, crtl->drap_reg,
+					-param_ptr_offset)));
       m->fs.cfa_reg = stack_pointer_rtx;
       m->fs.cfa_offset = param_ptr_offset;
       m->fs.sp_offset = param_ptr_offset;
       m->fs.realigned = false;
 
       add_reg_note (insn, REG_CFA_DEF_CFA,
-		    gen_rtx_PLUS (Pmode, stack_pointer_rtx,
-				  GEN_INT (param_ptr_offset)));
+		    plus_constant (Pmode, stack_pointer_rtx,
+				   param_ptr_offset));
       RTX_FRAME_RELATED_P (insn) = 1;
 
       if (!call_used_or_fixed_reg_p (REGNO (crtl->drap_reg)))
@@ -9711,8 +9710,8 @@  ix86_expand_split_stack_prologue (void)
       */
       words = TARGET_64BIT ? 3 : 5;
       emit_insn (gen_rtx_SET (scratch_reg,
-			      gen_rtx_PLUS (Pmode, frame_reg,
-					    GEN_INT (words * UNITS_PER_WORD))));
+			      plus_constant (Pmode, frame_reg,
+					     words * UNITS_PER_WORD)));
 
       varargs_label = gen_label_rtx ();
       emit_jump_insn (gen_jump (varargs_label));
@@ -9730,8 +9729,8 @@  ix86_expand_split_stack_prologue (void)
   if (cfun->machine->split_stack_varargs_pointer != NULL_RTX)
     {
       emit_insn (gen_rtx_SET (scratch_reg,
-			      gen_rtx_PLUS (Pmode, stack_pointer_rtx,
-					    GEN_INT (UNITS_PER_WORD))));
+			      plus_constant (Pmode, stack_pointer_rtx,
+					     UNITS_PER_WORD)));
 
       emit_label (varargs_label);
       LABEL_NUSES (varargs_label) = 1;
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index b426c21d3dd..6f3ac3ad555 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -1711,8 +1711,8 @@ 
   split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
 
   operands[1] = gen_lowpart (DImode, operands[2]);
-  operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (Pmode, stack_pointer_rtx,
-						   GEN_INT (4)));
+  operands[2] = gen_rtx_MEM (SImode,
+			     plus_constant (Pmode, stack_pointer_rtx, 4));
 })
 
 (define_insn "*pushsi2"
@@ -17223,12 +17223,12 @@ 
   if (!ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (operands[3])))
     FAIL;
 
-  rtx adjust = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[1])));
+  int piece_size = GET_MODE_SIZE (GET_MODE (operands[1]));
 
   /* If .md ever supports :P for Pmode, these can be directly
      in the pattern above.  */
-  operands[5] = gen_rtx_PLUS (Pmode, operands[0], adjust);
-  operands[6] = gen_rtx_PLUS (Pmode, operands[2], adjust);
+  operands[5] = plus_constant (Pmode, operands[0], piece_size);
+  operands[6] = plus_constant (Pmode, operands[2], piece_size);
 
   /* Can't use this if the user has appropriated esi or edi.  */
   if ((TARGET_SINGLE_STRINGOP || optimize_insn_for_size_p ())
@@ -17442,9 +17442,9 @@ 
 
   /* If .md ever supports :P for Pmode, this can be directly
      in the pattern above.  */
-  operands[3] = gen_rtx_PLUS (Pmode, operands[0],
-			      GEN_INT (GET_MODE_SIZE (GET_MODE
-						      (operands[2]))));
+  operands[3] = plus_constant (Pmode, operands[0],
+			       GET_MODE_SIZE (GET_MODE (operands[2])));
+
   /* Can't use this if the user has appropriated eax or edi.  */
   if ((TARGET_SINGLE_STRINGOP || optimize_insn_for_size_p ())
       && !(fixed_regs[AX_REG] || fixed_regs[DI_REG]))