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]

[PATCH] Minor improvement to expand_copysign


This tweak to expand_copysign is the lesser of two halves of a fix for
PR middle-end/19697 which is an ICE-on-valid regression against mainline.

The problem is actually an issue in the PA back-end, that was latent until
the recent change to introduce an RTL expander for the copysign built-in.
The issue is that when attempting to emit a bit-wise AND insn with two
integer constant operands, the constraint predicates for pa.md's anddi3
define_expand incorrectly allowed/accepted a form with an integer constant
as the first operand and a register as the second, that subsequently
failed to be recognized.  A patch to fix this should finish regression
testing on my PA box shortly.

However, the copysign RTL expander should probably be doing a slightly
better job of optimization to avoid generating ANDs of two immediate
constants.  Implemented by the patch below.


The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", all default languages, and regression tested with a
top-level "make -k check" with no new failures.

Ok for mainline?  Probably obvious but I want to synchronize with RTH
who's still making changes in this part of the compiler.



2005-01-30  Roger Sayle  <roger@eyesopen.com>

	* optabs.c (expand_copysign): Improve initial RTL generation when
	either argument to copysign is a compile-time constant.


Index: optabs.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/optabs.c,v
retrieving revision 1.254
diff -c -3 -p -r1.254 optabs.c
*** optabs.c	28 Jan 2005 00:54:58 -0000	1.254
--- optabs.c	30 Jan 2005 19:43:56 -0000
*************** expand_copysign (rtx op0, rtx op1, rtx t
*** 2689,2702 ****
        lo = 0;
      }

!   op0 = expand_binop (imode, and_optab,
! 		      gen_lowpart (imode, op0),
! 		      immed_double_const (~lo, ~hi, imode),
! 		      NULL_RTX, 1, OPTAB_LIB_WIDEN);
!   op1 = expand_binop (imode, and_optab,
! 		      gen_lowpart (imode, op1),
! 		      immed_double_const (lo, hi, imode),
! 		      NULL_RTX, 1, OPTAB_LIB_WIDEN);
    if (op0 && op1)
      {
        target = expand_binop (imode, ior_optab, op0, op1, NULL,
--- 2689,2708 ----
        lo = 0;
      }

!   op0 = gen_lowpart (imode, op0);
!   temp = immed_double_const (~lo, ~hi, imode);
!   op0 = (GET_CODE (op0) == CONST_INT || GET_CODE (op0) == CONST_DOUBLE)
! 	? simplify_binary_operation (AND, imode, op0, temp)
! 	: expand_binop (imode, and_optab, op0, temp,
! 			NULL_RTX, 1, OPTAB_LIB_WIDEN);
!
!   op1 = gen_lowpart (imode, op1);
!   temp = immed_double_const (lo, hi, imode);
!   op1 = (GET_CODE (op1) == CONST_INT || GET_CODE (op1) == CONST_DOUBLE)
! 	? simplify_binary_operation (AND, imode, op1, temp)
! 	: expand_binop (imode, and_optab, op1, temp,
! 			NULL_RTX, 1, OPTAB_LIB_WIDEN);
!
    if (op0 && op1)
      {
        target = expand_binop (imode, ior_optab, op0, op1, NULL,


Roger
--


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