[llvm-commits] [PATCH][Fastmath, Instcombine] Enhancement of Fdiv

Shuxin Yang shuxin.llvm at gmail.com
Mon Jan 14 14:57:26 PST 2013


Hi, Steve:

    You are right. I guess we need a "allow reassociation" relax level 
(and it is a medium relax level).
    I restructure my change (just committed)  in order to easily adapt 
to potential future change.
   The changes are sketched bellow:

   1) I introduce two bool to guard the transformation: "hasReassociate" 
and "hasReciprocal".  There are
considered independent in my new code. In the future, if someone 
introduce the "reassociate"-relax level,
we need only to change the "hasReassociate = xxx" statement, and rest 
code remains unchanged.

   2) (X/C1)/C2 is first transformed into X/(C1*C2), and optionally 
transformed into X* (1/(C1*C2)) if
      we 1/(C1*C2) is exact, or reciprocal is allowed.


Thanks
Shuxin




On 1/11/13 5:14 PM, Stephen Canon wrote:
>> Does (X / C1) / C2 ==> X / (C1 * C2) preserve more precision than reciprocal? The idea behind UnsafeAlgebra (commonly denoted as "fast") is that if you're allowing unsafe algebraic transformations like reassociation, then you're already throwing a level of caution to the wind, and all other flags should be implied. If allowing reassociation of constants does guarantee more precision, and there are users who would desire that but not reciprocal or other aspects of "fast", then I'm ok with the idea of splitting out another flag. It'd be nice having help/guidance doing so, of course :-)
> In general, (X/C1)/C2 --> X/(C1*C2) is not any worse than X/C1 --> X*(1/C1) (in particular, its *much* less offensive than reassociating additions).  It's conceivable that we may really want to have:
>
> 	- allow reassociation of multiplication and division, and replacement of division with reciprocal multiply.
> 	- fast (arbitrary algebraic transforms)
>
> instead of having reciprocal be alone in the first category.
>
> - Steve
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list