[PATCH] D63896: [GVN] Add support for unary FNeg to GVN pass

Cameron McInally via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 13:48:19 PDT 2019


cameron.mcinally created this revision.
cameron.mcinally added reviewers: spatel, arsenm, craig.topper, andrew.w.kaylor, kpn.
Herald added subscribers: llvm-commits, hiraditya, wdng.
Herald added a project: LLVM.

Repository:
  rL LLVM

https://reviews.llvm.org/D63896

Files:
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/test/Transforms/GVN/fpmath.ll


Index: llvm/test/Transforms/GVN/fpmath.ll
===================================================================
--- llvm/test/Transforms/GVN/fpmath.ll
+++ llvm/test/Transforms/GVN/fpmath.ll
@@ -43,9 +43,8 @@
 
 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
Index: llvm/lib/Transforms/Scalar/GVN.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/GVN.cpp
+++ llvm/lib/Transforms/Scalar/GVN.cpp
@@ -492,6 +492,7 @@
   switch (I->getOpcode()) {
     case Instruction::Call:
       return lookupOrAddCall(cast<CallInst>(I));
+    case Instruction::FNeg:
     case Instruction::Add:
     case Instruction::FAdd:
     case Instruction::Sub:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63896.206924.patch
Type: text/x-patch
Size: 1053 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190627/6054eeab/attachment.bin>


More information about the llvm-commits mailing list