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

Alexander Malyshev lostphifunction at gmail.com
Mon Dec 26 23:03:34 PST 2011


Thanks, and yeah it looks cleaner now.

Alex

On Tue, Dec 27, 2011 at 1:32 AM, Nick Lewycky <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
>> http://lists.cs.uiuc.edu/**mailman/listinfo/llvm-commits<http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111227/05d96c7a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cos.diff
Type: text/x-patch
Size: 3463 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111227/05d96c7a/attachment.bin>


More information about the llvm-commits mailing list