PR57073 - Optimize __builtin_powif (-1.0, k) to k & 1 ? -1.0 : 1.0
Tobias Burnus
burnus@net-b.de
Thu May 30 18:08:00 GMT 2013
The attached patch optimizes
__result_f = __builtin_powif (-1.0e+0, k);
to
powi_cond_4 = k_1(D) & 1;
powi_5 = powi_cond_4 ? -1.0e+0 : 1.0e+0;
I did an all-language (all,ada,go,objc++) bootstrap and regtest on
x86-64-gnu-linux.
OK for the trunk?
Additionally, I would like to thank Thomas, who tried several approaches
(e.g. fold_builtin_powi - which turned out to failed when called during
optimization time, as regimplifing had problems with the COND_EXPR) and
paved the way for this patch. And to Jakub, who gave helpful hints.
Note: Other replacements are also possible, e.g. "1.0 - (float) ((k & 1)
<< 1)". However, the condition above turned out to be fasted as Jakub
expected and Thomas has tested (see PR).
Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: powi.diff
Type: text/x-patch
Size: 2632 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20130530/661cad94/attachment.bin>
More information about the Gcc-patches
mailing list