[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

Lily Orth-Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 25 13:30:20 PDT 2023


electriclilies created this revision.
Herald added subscribers: bviyer, Moerafaat, zero9178, bzcheeseman, awarzynski, sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini.
Herald added a reviewer: ftynse.
Herald added a reviewer: dcaballe.
Herald added a project: All.
electriclilies requested review of this revision.
Herald added a reviewer: nicolasvasilache.
Herald added subscribers: cfe-commits, stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, MLIR.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151492

Files:
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
  mlir/test/Dialect/LLVMIR/call-intrin.mlir


Index: mlir/test/Dialect/LLVMIR/call-intrin.mlir
===================================================================
--- mlir/test/Dialect/LLVMIR/call-intrin.mlir
+++ mlir/test/Dialect/LLVMIR/call-intrin.mlir
@@ -11,7 +11,7 @@
 llvm.func @round_sse41() -> vector<4xf32> {
     %0 = llvm.mlir.constant(1 : i32) : i32
     %1 = llvm.mlir.constant(dense<0.2> : vector<4xf32>) : vector<4xf32>
-    %res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : (vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {}
+    %res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : (vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {fastmathFlags = #llvm.fastmath<reassoc>}
     llvm.return %res: vector<4xf32>
 }
 
Index: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
===================================================================
--- mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -16,15 +16,12 @@
 #include "mlir/Support/LLVM.h"
 #include "mlir/Target/LLVMIR/ModuleTranslation.h"
 
-//#include "llvm/IR/Attributes.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/MatrixBuilder.h"
 #include "llvm/IR/Operator.h"
 
-#include "mlir/Conversion/ArithCommon/AttrToLLVMConverter.h"
-
 using namespace mlir;
 using namespace mlir::LLVM;
 using mlir::LLVM::detail::createIntrinsicCall;
@@ -118,16 +115,11 @@
   } else {
     fn = llvm::Intrinsic::getDeclaration(module, id, {});
   }
-  llvm::errs() << "hi\n";
   Operation* op2 = op;
-  llvm::errs() << "hi2\n";
-  if (auto fmf = dyn_cast<FastmathFlagsInterface>(op2)) {
-    llvm::errs() << "setting fastmath flags\n";
+  if (auto fmf = dyn_cast<FastmathFlagsInterface>(op2))
     builder.setFastMathFlags(getFastmathFlags(fmf));
-    llvm::errs() << "done\n";
-  }
 
-  llvm::CallInst *inst =
+  auto *inst =
       builder.CreateCall(fn, moduleTranslation.lookupValues(op.getOperands()));
 
   if (op.getNumResults() == 1)
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===================================================================
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -364,7 +364,6 @@
 
   // Copy function attributes over, we have no argument or return attributes
   // that can be valid on the real entry.
-  // This is what I want to do
   AttributeList NewAttrs = AttributeList::get(Ctx, AttributeList::FunctionIndex,
                                               Fn->getAttributes().getFnAttrs());
   EntryFn->setAttributes(NewAttrs);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151492.525774.patch
Type: text/x-patch
Size: 2634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230525/62ebeed3/attachment.bin>


More information about the cfe-commits mailing list