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, i386]: Introduce x86_should_negate_const_int_p predicate


Hello!

Attached patch introduces x86_should_negate_const_int_p predicate in
places that negate const ints in order to generate smaller or
"cleaner" (i.e. sub XX, %reg instead of add -XX, %reg) asm code. The
predicate is also enhanced to perform checks for overflow when trying
to negate 0x80...0 to all modes.

The patch also introduces this functionality to locked add instructions.

2010-02-12  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/i386.c (x86_should_negate_const_int_p): New.
	* config/i386/i386-protos.h: Declare it.
	* config/i386/i386.md (*add<mode>_1, *addsi_1_zext, *addhi_1,
	*addhi_1_lea, *addqi_1, *addqi_1_lea, *addqi_1_slp, *add<mode>_2,
	*addsi_2_zext, *addhi_2, *addqi_2, *add<mode>_3, *addsi_3_zext,
	*addhi_3, *addqi_3,*add<mode>_5, *addhi_5, *addqi_5):
	Use x86_should_negate_const_int_p to output insn mnemonic.
	(*adddi_4, *addsi_4, *addhi_4, *addqi_4): Ditto.  Remove overflow
	check from instruction predicate.  Update comments.
	* config/i386/sync.c (sync_add<mode>): Use
	x86_should_negate_const_int_p to output insn mnemonic.

Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32}.

The patch is fairly safe, but I'll leave to RMs to decide if it can be
committed to 4.5.

Uros.

Attachment: i386-add.diff.txt
Description: Text document


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