Patch to optabs.c

Jeffrey A Law law@redhat.com
Mon Jan 1 16:45:00 GMT 2001


  In message <482569C1.00321815.00@smtp.sunplus.com.tw>you write:
  > The following patch fixes a bug in expand_binop(). When the operation is
  > add or sub, the original optabs.c forgets to copy the result of first word
  > back to target.
  > 
  > I am porting GCC to a 16-bit micro-processor. When I feed the testsuite 
  > into the ported GCC, I found this bug. After add this patch, the GCC works
  > fine and generates correct codes.
The only way I can see this kind of problem happening is when i == 0
and expand_binop puts its result somewhere other than TARGET_PIECE (which
is possible according to the definition of expand_binop).

If that's indeed what's happening, why not put that code fragment 
immediately after the first call to expand_binop in the loop (as
opposed to your solution of putting it at the bottom of the loop)?

ie, something like this:

          /* Main add/subtract of the input operands.  */
          x = expand_binop (word_mode, binoptab,
                            op0_piece, op1_piece,
                            target_piece, unsignedp, next_methods);
          if (x == 0)
            break;
	  else if (target_piece != x)
	    emit_move_insn (target_piece, x);

If that works, please send an updated patch to gcc-patches@gcc.gnu.org.

Cheers,
jeff



More information about the Gcc-patches mailing list