[llvm] r342081 - Guard FMF context by excluding some FP operators from FPMathOperator

Michael Berg via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 12 14:09:59 PDT 2018


Author: mcberg2017
Date: Wed Sep 12 14:09:59 2018
New Revision: 342081

URL: http://llvm.org/viewvc/llvm-project?rev=342081&view=rev
Log:
Guard FMF context by excluding some FP operators from FPMathOperator

Summary:
Some FPMathOperators succeed and the retrieve FMF context when they never have it, we should omit these cases to keep from removing FMF context.

For instance when we visit some FPMathOperator mapped Instructions which never have FMF flags and a Node was associated which does have FMF flags, that Node today will have all its flags cleared via the intersect operation.  With this change, we exclude associating Nodes that never have FPMathOperator status under FMF.

Reviewers: spatel, wristow, arsenm, hfinkel, aemerson

Reviewed By: spatel

Subscribers: llvm-commits, wdng

Differential Revision: https://reviews.llvm.org/D51145

Modified:
    llvm/trunk/include/llvm/IR/Operator.h
    llvm/trunk/test/CodeGen/X86/intersect-fma-fmf.ll

Modified: llvm/trunk/include/llvm/IR/Operator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Operator.h?rev=342081&r1=342080&r2=342081&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Operator.h (original)
+++ llvm/trunk/include/llvm/IR/Operator.h Wed Sep 12 14:09:59 2018
@@ -364,19 +364,26 @@ public:
   /// precision.
   float getFPAccuracy() const;
 
-  static bool classof(const Instruction *I) {
-    return I->getType()->isFPOrFPVectorTy() ||
-      I->getOpcode() == Instruction::FCmp;
-  }
-
-  static bool classof(const ConstantExpr *CE) {
-    return CE->getType()->isFPOrFPVectorTy() ||
-           CE->getOpcode() == Instruction::FCmp;
-  }
-
   static bool classof(const Value *V) {
-    return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
-           (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
+    unsigned Opcode;
+    if (auto *I = dyn_cast<Instruction>(V))
+      Opcode = I->getOpcode();
+    else if (auto *CE = dyn_cast<ConstantExpr>(V))
+      Opcode = CE->getOpcode();
+    else
+      return false;
+
+    switch (Opcode) {
+    case Instruction::FCmp:
+      return true;
+    // non math FP Operators (no FMF)
+    case Instruction::ExtractElement:
+    case Instruction::ShuffleVector:
+    case Instruction::InsertElement:
+      return false;
+    default:
+      return V->getType()->isFPOrFPVectorTy();
+    }
   }
 };
 

Modified: llvm/trunk/test/CodeGen/X86/intersect-fma-fmf.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/intersect-fma-fmf.ll?rev=342081&r1=342080&r2=342081&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/intersect-fma-fmf.ll (original)
+++ llvm/trunk/test/CodeGen/X86/intersect-fma-fmf.ll Wed Sep 12 14:09:59 2018
@@ -3,8 +3,7 @@
 define float @test_x86_fma_intersection_fmf(float %a, float %b) {
 ; CHECK-LABEL: test_x86_fma_intersection_fmf:
 ; CHECK:      # %bb.0:
-; CHECK:        vmulss {{[0-9]+}}(%esp), %xmm0, %xmm1
-; CHECK-NEXT:   vaddss %xmm0, %xmm1, %xmm0
+; CHECK:        vfmadd132ss {{[0-9]+}}(%esp), %xmm0, %xmm0
 ; CHECK:        retl 
      %tmp8 = fmul fast float %a, %b
      %tmp9 = fadd fast float %tmp8, %b




More information about the llvm-commits mailing list