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 v4] PR target/30315 i386 missed optimization detecting overflows


On Tue, Aug 14, 2007 at 03:34:53PM +0200, Paolo Bonzini wrote:
> 
> >+/* Canonicalize overflow checks to save on the insn patterns. We change
> >+   "a + b < b" into "a + b < a" and "a + b >= b" into "a + b >= a".  */
> >+#define CANONICALIZE_COMPARISON(code, op0, op1)	\
> >+{						\
> >+  if ((code == LTU || code == GEU)		\
> >+      && GET_CODE (op0) == PLUS			\
> >+      && rtx_equal_p (op1, XEXP (op0, 1)))	\
> >+    op1 = XEXP (op0, 0);			\
> >+}
> 
> Sorry for complicating your useful work.
> 
> It looks to me like this canonicalization belongs in simplify-rtx.c.  Of 
> course, this can be done in a follow-up patch.

   I agree. We also want to do something at the tree level so

	sum = a + b;
	if (sum < a)
		abort ();
	if (sum < b)
		abort ();

is optimized into

	sum = a + b;
	if (sum < a)
		abort ();

-- 
Rask Ingemann Lambertsen


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