[llvm-commits] [PATCH] SimplifyLibCalls.cpp: Small cosine optimization
Nick Lewycky
nicholas at mxc.ca
Mon Dec 26 22:32:19 PST 2011
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
More information about the llvm-commits
mailing list