This is the mail archive of the 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]

apparent typo in combine.c

This code from combine.c::make_compound_operation() looks wrong to me.

    case LSHIFTRT:
      /* If the sign bit is known to be zero, replace this with an
	 arithmetic shift.  */
      if (ashr_optab->handlers[(int) mode].insn_code == CODE_FOR_nothing
	  && lshr_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing
	  && mode_width <= HOST_BITS_PER_WIDE_INT
	  && (nonzero_bits (XEXP (x, 0), mode) & (1 << (mode_width - 1))) == 0)
	  new = gen_rtx_ASHIFTRT (mode,
				  make_compound_operation (XEXP (x, 0),
				  XEXP (x, 1));

As I read it, this means: if we are working on a logical shift right,
and we *don't* have an arithmetic shift right for this mode, and we *do*
have a logical shift right, and some other stuff, then replace the logical
shift with an arithmetic shift.

Now how can that be right?  Generate an arithmetic shift only if we
*don't* have an arithmetic shift insn for this mode?  I would think
that either the != and == should be swapped in the first two lines,
or we should change the first line to != and lose the test of lshr_optab
entirely (on the theory that we prefer generating arithmetic shifts).



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