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

Eli Friedman eli.friedman at gmail.com
Fri Jan 11 14:56:58 PST 2013


On Fri, Jan 11, 2013 at 2:47 PM,  <dag at cray.com> wrote:
> Shuxin Yang <shuxin.llvm at gmail.com> writes:
>
>>     1) reciprocal.patch:
>>         implement reciprocal rule:
>>          1.1   X/C => X *(1/C) if 1/C is neither special value nor
>> denormal.
>>
>>        This rule could incur noticeable rounding errors (sometimes up
>> to 0.001% -- one testing case
>>       in pollybench suite see a diff between 1.003 and 1.004, and the
>> "huge" difference is caused
>>       by a single transformation X/1000 => X * 0.001).
>
> Is this rule controlled by strict fp or other options?  Users should be
> able to disable it for precision.
>
>>    2. fdiv.patch implement a slew of fdiv related rules:
>>
>>       2.1). (X/C1) / C2 => X * (1/(C2*C1))
>
> Why not do (X/C1) / C2 => X / (C1 * C2) (under switch control) and let
> 1.1 clean it up if allowed by the previously-explained user switch?
>
>>       2.2). X*C1 / C2 => X * (C1/C2)
>
> This will need a strict or similar switch control for fp arithmetic.
>
>>       2.3). (X/Y)/Z = > X/(Y*Z)  (at least one of Y and Z is symbolic
>> value)
>>       2.4). Z/(X/Y) = > (Z*Y)/X
>>       2.5). C1/(X*C2) => (C1/C2) / X
>>       2.6). C1/(X/C2) => (C1*C2) / X
>>       2.7) C1/(C2/X) => (C1/C2) * X
>
> And all of these too.
>
> Every single one of these transformations can change fp arithmetic
> answers and thus we must have a way to disable them on the command line.

We're only doing these transformations for instructions marked "fast"
(http://llvm.org/docs/LangRef.html#fast-math-flags), i.e. compiled
with -ffast-math .  Giving each individual transform a flag seems like
way more detail than is actually useful.

-Eli



More information about the llvm-commits mailing list