From fd11f0fdb72e0c9affa61ffd4491f36d7ff2f1e2 Mon Sep 17 00:00:00 2001 From: Cameron McInally Date: Thu, 27 Jun 2019 21:05:02 +0000 Subject: [PATCH] [GVN] Add support for unary FNeg to GVN pass Differential Revision: https://reviews.llvm.org/D63896 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364592 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/GVN.cpp | 1 + test/Transforms/GVN/fpmath.ll | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 5edc6c2ab0b..1a02e9d33f4 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -492,6 +492,7 @@ uint32_t GVN::ValueTable::lookupOrAdd(Value *V) { switch (I->getOpcode()) { case Instruction::Call: return lookupOrAddCall(cast(I)); + case Instruction::FNeg: case Instruction::Add: case Instruction::FAdd: case Instruction::Sub: diff --git a/test/Transforms/GVN/fpmath.ll b/test/Transforms/GVN/fpmath.ll index 60e72e4f287..dddc45e25cd 100644 --- a/test/Transforms/GVN/fpmath.ll +++ b/test/Transforms/GVN/fpmath.ll @@ -43,9 +43,8 @@ define double @test4(double %x, double %y) { define double @test5(double %x, double %y) { ; CHECK: @test5(double %x, double %y) -; CHECK: %neg1 = fneg double %x, !fpmath !0 -; CHECK: %neg2 = fneg double %x, !fpmath !1 -; CHECK: %foo = fadd double %neg1, %neg2 +; CHECK: %neg1 = fneg double %x, !fpmath !1 +; CHECK: %foo = fadd double %neg1, %neg1 %neg1 = fneg double %x, !fpmath !0 %neg2 = fneg double %x, !fpmath !1 %foo = fadd double %neg1, %neg2 -- 2.50.1