[llvm-commits] [PATCH] SimplifyLibCalls.cpp: Small cosine optimization

Nick Lewycky nicholas at mxc.ca
Tue Dec 27 10:36:58 PST 2011


On 12/26/2011 11:03 PM, Alexander Malyshev wrote:
> Thanks, and yeah it looks cleaner now.

I made some truly minor changes and submitted it as r147291. Thanks for 
the patch!

Nick

>
> Alex
>
> On Tue, Dec 27, 2011 at 1:32 AM, Nick Lewycky <nicholas at mxc.ca
> <mailto:nicholas at mxc.ca>> wrote:
>
>     On 12/26/2011 09:04 PM, Alexander Malyshev wrote:
>
>         Adds the pattern for cos(-x) -> cos(x). Test file included.
>
>
>     +    // cos(-x) -> cos(x)
>     +    Value *Op1 = CI->getArgOperand(0);
>     +    if (BinaryOperator *BinExpr = dyn_cast<BinaryOperator>(Op1)) {
>     +      if (ConstantFP *C =
>     dyn_cast<ConstantFP>(BinExpr->__getOperand(0))) {
>     +        if (BinExpr->getOpcode() == Instruction::FSub &&
>     +            C->getValueAPF().isZero()) {
>
>     I think you can simplify this using BinExpr->isFNeg()?
>
>     This looks great overall, if that simplification works please resend
>     an updated patch!
>
>     Nick
>
>     +          Value *X = BinExpr->getOperand(1);
>     +          return B.CreateCall(Callee, X, "");
>     +        }
>     +      }
>     +    }
>
>
>         Alex
>
>
>
>         _________________________________________________
>         llvm-commits mailing list
>         llvm-commits at cs.uiuc.edu <mailto:llvm-commits at cs.uiuc.edu>
>         http://lists.cs.uiuc.edu/__mailman/listinfo/llvm-commits
>         <http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>
>
>
>




More information about the llvm-commits mailing list