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

Shuxin Yang shuxin.llvm at gmail.com
Wed Dec 12 16:58:50 PST 2012


I just re-read the InstCombiner::SimplifyAssociateOrCommutative().
It is pretty simple, it can only handle adjacent instructions with 
exactly the same opcode.
(1*5 * x) - x is certainly beyond its scope.

Do we need to expand it to be more capable?  I don't like this idea 
because :
   - add/sub is most difficult to tackle than other ops. I don't like 
just to make add/sub
     happy at the cost of slowing down other operators.

   - it has to rely on pattern match......

> (Please read this part carefully; sorry it took me longer than I
> should have to figure this out.)  I think it's worth comparing this
> patch to what we do for integer operations.  For integer operations,
> we handle the transformations you cited with a combination of
> InstCombiner::SimplifyAssociativeOrCommutative,
> InstCombiner::SimplifyUsingDistributiveLaws, and a few simple
> peepholes which I'm pretty sure are already implemented for fadd.
> Would it be possible to extend those methods instead of implementing
> new infrastructure for floating-point?




More information about the llvm-commits mailing list