[llvm-commits] [PATCH][FastMath, InstCombine] Fadd/Fsub optimizations

Shuxin Yang shuxin.llvm at gmail.com
Mon Dec 17 17:12:57 PST 2012


The "quota <= #-of-instruction - 1", which translates to : if input expr 
has N instruction, the output simplified expr has no more than
N-1 instruction.

While the size of simplified expr in question is always reduced, the 
overall instruction # may not be reduced.
e.g. Input sequence has 3 instr, among them one instruction has multiple 
uses.
        The output sequence has 2 (new) instructions.  Although it 
reduces  1 instruction from
        the expr, the original sub-expr which has multi-use still alive, 
so the transformation doesn't save instr
        from the entire function's perspective.

On 12/17/12 5:01 PM, Eli Friedman wrote:
> On Mon, Dec 17, 2012 at 4:55 PM, Shuxin Yang <shuxin.llvm at gmail.com> wrote:
>>> By the same logic, why isn't the quota 3 for the case where nothing is
>>> multi-use? Or are you concerned about the transformation falling into an
>>> infinite loop?
>> I only try to optimize "this instruction" along with at most two neighboring
>> instructions.
>> So the input has at most 3 instr, and the up-bound for the output quota is
>> 3-1 = 2.
>>
>> I don't like to scale this optimization in InstCombine as it supposed to be
>> extremely fast.
> Have you given any thought to the possibility that the "simplified"
> form could be the same as the original instruction?  I don't think
> it's possible given the current way you're setting the quotas, but
> your code doesn't seem to have any defense against the infinite loop
> which would result.
>
> -Eli




More information about the llvm-commits mailing list