On 09/09/15 22:51, Jeff Law wrote:
On 09/02/2015 07:43 AM, Kyrill Tkachov wrote:

+  rtx_code code; +  if (val_a == -val_b)
Do we have to worry about signed overflow here?  I'm thinking
specifically when val_b is the smallest possible integer
representable by a HOST_WIDE_INT.  I suspect you may be able to
avoid these problems with judicious use of the hwi interfaces.
I understand the issue, but am not sure what hwi interfaces to use
here. Seems that the problem will be if val_b is HOST_WIDE_INT_MIN.
Right.  When val_b is HOST_WIDE_INT_MIN, negating it will overflow.

Looking at the definition of abs_hwi in hwint.h before it negates
it's argument it asserts that it's not HOST_WIDE_INT_MIN. I think
that's to avoid this exact issue? If so, I've added a check for
HOST_WIDE_INT_MIN which should cover the undefined case when negating
a HOST_WIDE_INT, unless there's something else I'm missing.
That should be sufficient.

2015-09-02  Kyrylo Tkachov <kyrylo.tkac...@arm.com>

       * ifcvt.c (noce_try_inverse_constants): New function.
       (noce_process_if_block): Call it.
       * optabs.h (emit_conditional_neg_or_complement): Declare prototype.
       * optabs.def (negcc_optab, notcc_optab): Declare.
       * optabs.c (emit_conditional_neg_or_complement): New function.
       * doc/tm.texi (Standard Names): Document negcc, notcc names.

OK for the trunk.

Thanks for the review.
I'll commit it if/when the aarch64 and arm implementations of the hooks
in patches 2/3 and 3/3 are approved.

Kyrill


Thanks for your patience.

Jeff


Reply via email to