[PATCH] D51145: Guard FMF context by excluding some FP operators from FPMathOperator

Michael Berg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 12 14:11:17 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL342081: Guard FMF context by excluding some FP operators from FPMathOperator (authored by mcberg2017, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51145?vs=164970&id=165149#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51145

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


Index: llvm/trunk/include/llvm/IR/Operator.h
===================================================================
--- llvm/trunk/include/llvm/IR/Operator.h
+++ llvm/trunk/include/llvm/IR/Operator.h
@@ -364,19 +364,26 @@
   /// 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();
+    }
   }
 };
 
Index: llvm/trunk/test/CodeGen/X86/intersect-fma-fmf.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/intersect-fma-fmf.ll
+++ llvm/trunk/test/CodeGen/X86/intersect-fma-fmf.ll
@@ -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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51145.165149.patch
Type: text/x-patch
Size: 1940 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180912/2c9ffc49/attachment.bin>


More information about the llvm-commits mailing list