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] Fix neg_const_int (PR rtl-optimization/78546)


On 11/28/2016 10:30 AM, Jakub Jelinek wrote:
Hi!

For TImode and wider, neg_const_int returns wrong value for
(const_int 0x8000000000000000) - the argument unmodified.
The function comment above the function kind of suggests that it
truncates, but I fail to see which caller might benefit from such
behavior, it would mean having to guard against the problematic
value in all the spots.
This patch fixes it by returning correct return value from the function,
and in one caller which assumed it would always return a CONST_INT
rather than CONST_DOUBLE/CONST_WIDE_INT changes it to optimize
only if CONST_INT has been returned.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2016-11-28  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/78546
	* simplify-rtx.c (neg_const_int): When negating most negative
	number in mode wider than HOST_BITS_PER_WIDE_INT, use
	simplify_const_unary_operation to produce CONST_DOUBLE or
	CONST_WIDE_INT.
	(simplify_plus_minus): Hanlde the case where neg_const_int
	doesn't return a CONST_INT.

	* gcc.dg/torture/pr78546-1.c: New test.
	* gcc.dg/torture/pr78546-2.c: New test.
OK.
jeff


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