This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH]: Simplify inside CONST expressions



! if (GET_CODE (lhs) == CONST && GET_CODE (rhs) == CONST
! && GET_MODE (lhs) == GET_MODE (rhs))
! {
! tem = simplify_binary_operation (ncode, mode, ! XEXP (lhs, 0),
! XEXP (rhs, 0));
! if (!CONSTANT_P (tem))
! tem = gen_rtx_CONST (GET_MODE (lhs), tem);
! }
! else
! tem = simplify_binary_operation (ncode, mode, lhs, rhs);

What about this instead:


  {
    rtx tem_lhs = GET_CODE (lhs) == CONST ? XEXP (lhs, 0) : lhs;
    rtx tem_rhs = GET_CODE (rhs) == CONST ? XEXP (rhs, 0) : rhs;
    tem = simplify_binary_operation (ncode, mode, tem_lhs, tem_rhs);
    if (GET_CODE (lhs) == CONST && GET_CODE (rhs) == CONST)
      {
        gcc_assert (GET_MODE (lhs) == GET_MODE (rhs));
        if (!CONSTANT (tem))
          tem = gen_rtx_CONST (GET_MODE (lhs), tem);
      }
  }

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]