]> granicus.if.org Git - llvm/commitdiff
[GVN] Add support for unary FNeg to GVN pass
authorCameron McInally <cameron.mcinally@nyu.edu>
Thu, 27 Jun 2019 21:05:02 +0000 (21:05 +0000)
committerCameron McInally <cameron.mcinally@nyu.edu>
Thu, 27 Jun 2019 21:05:02 +0000 (21:05 +0000)
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
test/Transforms/GVN/fpmath.ll

index 5edc6c2ab0b8cd5de9390edbbf6d94ea1a728499..1a02e9d33f49f29d0f4ad3d85e6aa22a469763c8 100644 (file)
@@ -492,6 +492,7 @@ uint32_t GVN::ValueTable::lookupOrAdd(Value *V) {
   switch (I->getOpcode()) {
     case Instruction::Call:
       return lookupOrAddCall(cast<CallInst>(I));
+    case Instruction::FNeg:
     case Instruction::Add:
     case Instruction::FAdd:
     case Instruction::Sub:
index 60e72e4f2870c21c4bdd0c97af16dcd875e70742..dddc45e25cdeb9564a03913c2e30943d993594e9 100644 (file)
@@ -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