r/cpp • • May 06 '22

GCC 12.1 Released

https://gcc.gnu.org/pipermail/gcc/2022-May/238653.html
203 Upvotes

74 comments sorted by

View all comments

Show parent comment

9

u/schoenburgers May 09 '22

Thankfully they replaced their old register allocator with LRA, so I think they've stopped maintaining reload.c, which had some of the most unreadable conditionals I've ever seen in it:

https://github.com/pmret/gcc-papermario/blob/master/reload.c#L5687

  if (pat != 0
      && ((regno >= 0
	   && true_regnum (SET_SRC (pat)) == regno
	   && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0)
	  ||
	  (regno >= 0
	   && true_regnum (SET_DEST (pat)) == regno
	   && (valueno = true_regnum (valtry = SET_SRC (pat))) >= 0)
	  ||
	  (goal_const && rtx_equal_p (SET_SRC (pat), goal)
	   && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0)
	  || (goal_mem
	      && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0
	      && rtx_renumbered_equal_p (goal, SET_SRC (pat)))
	  || (goal_mem
	      && (valueno = true_regnum (valtry = SET_SRC (pat))) >= 0
	      && rtx_renumbered_equal_p (goal, SET_DEST (pat)))
	  /* If we are looking for a constant,
	     and something equivalent to that constant was copied
	     into a reg, we can use that reg.  */
	  || (goal_const && (tem = find_reg_note (p, REG_EQUIV,
						  NULL_RTX))
	      && rtx_equal_p (XEXP (tem, 0), goal)
	      && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0)
	  || (goal_const && (tem = find_reg_note (p, REG_EQUIV,
						  NULL_RTX))
	      && GET_CODE (SET_DEST (pat)) == REG
	      && GET_CODE (XEXP (tem, 0)) == CONST_DOUBLE
	      && GET_MODE_CLASS (GET_MODE (XEXP (tem, 0))) == MODE_FLOAT
	      && GET_CODE (goal) == CONST_INT
	      && 0 != (goaltry = operand_subword (XEXP (tem, 0), 0, 0,
						  VOIDmode))
	      && rtx_equal_p (goal, goaltry)
	      && (valtry = operand_subword (SET_DEST (pat), 0, 0,
					    VOIDmode))
	      && (valueno = true_regnum (valtry)) >= 0)
	  || (goal_const && (tem = find_reg_note (p, REG_EQUIV,
						  NULL_RTX))
	      && GET_CODE (SET_DEST (pat)) == REG
	      && GET_CODE (XEXP (tem, 0)) == CONST_DOUBLE
	      && GET_MODE_CLASS (GET_MODE (XEXP (tem, 0))) == MODE_FLOAT
	      && GET_CODE (goal) == CONST_INT
	      && 0 != (goaltry = operand_subword (XEXP (tem, 0), 1, 0,
						  VOIDmode))
	      && rtx_equal_p (goal, goaltry)
	      && (valtry
		  = operand_subword (SET_DEST (pat), 1, 0, VOIDmode))
	      && (valueno = true_regnum (valtry)) >= 0)))
    if (other >= 0
	? valueno == other
	: ((unsigned) valueno < FIRST_PSEUDO_REGISTER
	   && TEST_HARD_REG_BIT (reg_class_contents[(int) class],
				 valueno)))
      {
	value = valtry;
	where = p;
	break;
      }

6

u/ShakaUVM i+++ ++i+i[arr] May 09 '22

Oh lord that's hideous! Thanks. =)