[PATCH] Moving MipsOptimizeMathLibCalls to Transforms/Scalar

Richard Sandiford rsandifo at linux.vnet.ibm.com
Thu Aug 22 08:51:34 PDT 2013


[started out as a thread on llvm-dev]

Akira Hatanaka <ahatanak at gmail.com> writes:
> Assuming it is okay to make this pass generic, I would consider running it
> as the last IR pass (at the end of TargetPassConfig::addIRPasses).

Yeah, I suppose we should make it opt-in for now, since it can only handle
sqrt at the moment.  I went for the more general name PartiallyInlineLibCalls
Just In Case though.  This optimisation seems to fit into the same
category as checking the first pair of bytes before caling strcmp, etc.

How does this look?  As you can see, most of it is lifted verbatim
from the MIPS version.  The only real difference is that we now use
TargetTransformInfo to check whether a sqrt instruction is available.
That should cope with the soft-float cases (including MIPS16).

For context, the original message was:

>> Richard Sandiford <rsandifo at linux.vnet.ibm.com> writes:
>> > MipsOptimizeMathLibCalls.cpp converts:
>> >
>> >   g = sqrt (f);
>> >
>> > into:
>> >
>> >   r1 = sqrt (f) readonly;
>> >   if (g is a NaN)
>> >     r2 = sqrt (f);
>> >   g = phi (r1, r2)
>> >
>> > I'd like to do the same on z.  Would it be OK to make this pass generic
>> > and do the transformation whenever FSQRT isLegalOrCustom for the type?
>> >
>> > If so, should it stay a separate pass, or should I merge it with
>> > something else?

Thanks,
Richard

-------------- next part --------------
A non-text attachment was scrubbed...
Name: partially-inline-libcalls.diff
Type: text/x-patch
Size: 22033 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130822/3657624d/attachment.bin>


More information about the llvm-commits mailing list