On Tue, 4 Oct 2016, Richard Biener wrote:

> On Tue, 4 Oct 2016, Joseph Myers wrote:
> > On Tue, 4 Oct 2016, Richard Biener wrote:
> > 
> > > Possibly.  Though then for FP we also want - abs (a) -> copysign (a, -1).
> > 
> > For architectures such as powerpc that have a negated-abs instruction, 
> > does it get properly generated from the copysign code?  (The relevant 
> > pattern in rs6000.md uses (neg (abs)) - is that the correct canonical RTL 
> > for this?)
> I have no idea - given that there is no copysign RTL code I suppose
> it is the only machine independent RTL that can do this?
> The question would be whether the copysign optab of said targets would
> special-case the -1 case appropriately.

Why -1?  Any constant in copysign should be handled appropriately.  I'd 
say that (neg (abs)) is probably better as a canonical representation, so 
map copysign from a constant to either (abs) or (neg (abs)) appropriately.

Then in the case where abs is expanded with bit manipulation, (neg (abs)) 
should be expanded to a single OR.  I don't know whether the RTL 
optimizers will map the AND / OR combination to a single OR, but if they 
do then there should be no need to special-case (neg (abs)) in expansion, 
and when (abs) RTL is generated a machine description's (neg (abs)) 
pattern should match automatically.

Joseph S. Myers

Reply via email to