[PATCH] D12096: [InstCombineAddSub opportunities]: More opportunities to factorize FAdd/FSub when unsafeAlgebra is present for Inst

Aditya Nandakumar via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 19:45:50 PDT 2015


aditya_nandakumar created this revision.
aditya_nandakumar added a reviewer: llvm-commits.
aditya_nandakumar added a subscriber: llvm-commits.
aditya_nandakumar set the repository for this revision to rL LLVM.

Canonicalizing negative constants out of expressions causes significant instruction count increase (not all of which is cleaned up by instcombine due to ordering of expressions)

The following patch tries factorize more combinations of FAdd/FSub instructions when unsafeAlgebra is set. This reduces the regression in codegen instructions from the above patch.

Some examples -
Here op* is restricted to FAdd/FSub.
// -> Transform (A op1 B) op2 C -> A op3 (B op4 C) if (B op4 C) factorizes
//    Eg. (A + X*C1) + X * C2 -> A + X* (C1 + C2)
// -> Transform A op1 (B op2 C) -> (A op3 B) op4 C) if (A op3 B) factorizes
//    Eg. (A + X*C1) - X*C2 -> A + X *(C1-C2)
// -> Transform ( A op1 B) op2 C -> (A op3 C) op4 B if (A op3 C) factorizes
//    Eg. (X * C1 - B) + X * C2 -> X * (C1 - C2) - B
// -> Transform A op1 (B op2 C) -> (A op3 C) op4 B
//    Eg. X * C1 - (B + X * C2) -> X * (C1 - C2) - B

I'll add test cases post feedback.

Repository:
  rL LLVM

http://reviews.llvm.org/D12096

Files:
  lib/Transforms/InstCombine/InstCombineAddSub.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12096.32374.patch
Type: text/x-patch
Size: 10137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150818/24485f08/attachment.bin>


More information about the llvm-commits mailing list