Skip to content

Commit

Permalink
Add InstCombine::visitFNeg(...)
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D61784

llvm-svn: 360461
  • Loading branch information
mcinally authored and MrSidims committed May 17, 2019
1 parent d908875 commit d36f48e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
9 changes: 9 additions & 0 deletions llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
Expand Up @@ -1821,6 +1821,15 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
return Changed ? &I : nullptr;
}

Instruction *InstCombiner::visitFNeg(UnaryOperator &I) {
if (Value *V = SimplifyFNegInst(I.getOperand(0), I.getFastMathFlags(),
SQ.getWithInstruction(&I)))
return replaceInstUsesWith(I, V);

return nullptr;
}


Instruction *InstCombiner::visitFSub(BinaryOperator &I) {
if (Value *V = SimplifyFSubInst(I.getOperand(0), I.getOperand(1),
I.getFastMathFlags(),
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Transforms/InstCombine/InstCombineInternal.h
Expand Up @@ -347,6 +347,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner
// I - Change was made, I is still valid, I may be dead though
// otherwise - Change was made, replace I with returned instruction
//
Instruction *visitFNeg(UnaryOperator &I);
Instruction *visitAdd(BinaryOperator &I);
Instruction *visitFAdd(BinaryOperator &I);
Value *OptimizePointerDifference(Value *LHS, Value *RHS, Type *Ty);
Expand Down
4 changes: 1 addition & 3 deletions llvm/test/Transforms/InstCombine/fneg.ll
Expand Up @@ -6,9 +6,7 @@ declare void @use(float)
define float @fneg_fneg(float %a) {
;
; CHECK-LABEL: @fneg_fneg(
; CHECK-NEXT: [[F:%.*]] = fneg float [[A:%.*]]
; CHECK-NEXT: [[R:%.*]] = fneg float [[F]]
; CHECK-NEXT: ret float [[R]]
; CHECK-NEXT: ret float [[A:%.*]]
;
%f = fneg float %a
%r = fneg float %f
Expand Down

0 comments on commit d36f48e

Please sign in to comment.