17
17
#include " llvm/SYCLLowerIR/SYCLSqrtFDivMaxErrorCleanUp.h"
18
18
19
19
#include " llvm/ADT/SmallSet.h"
20
- #include " llvm/IR/Module.h"
21
- #include " llvm/IR/IntrinsicInst.h"
22
20
#include " llvm/IR/IRBuilder.h"
21
+ #include " llvm/IR/IntrinsicInst.h"
22
+ #include " llvm/IR/Module.h"
23
23
24
24
using namespace llvm ;
25
25
@@ -29,8 +29,7 @@ static constexpr char FDIV_ERROR[] = "2.5";
29
29
} // namespace
30
30
31
31
PreservedAnalyses
32
- SYCLSqrtFDivMaxErrorCleanUpPass::run (Module &M,
33
- ModuleAnalysisManager &MAM) {
32
+ SYCLSqrtFDivMaxErrorCleanUpPass::run (Module &M, ModuleAnalysisManager &MAM) {
34
33
SmallVector<IntrinsicInst *, 16 > WorkListSqrt;
35
34
SmallVector<IntrinsicInst *, 16 > WorkListFDiv;
36
35
@@ -48,22 +47,22 @@ SYCLSqrtFDivMaxErrorCleanUpPass::run(Module &M,
48
47
49
48
for (auto *Use : F.users ()) {
50
49
auto *II = cast<IntrinsicInst>(Use);
51
- if (II && II-> getCalledFunction ()-> getName ().
52
- starts_with (" llvm.fpbuiltin" )) {
50
+ if (II &&
51
+ II-> getCalledFunction ()-> getName (). starts_with (" llvm.fpbuiltin" )) {
53
52
// llvm.fpbuiltin.* intrinsics should always have fpbuiltin-max-error
54
53
// attribute, but it's not a concern of the pass, so just do an early
55
54
// exit here if the attribute is not attached.
56
55
if (!II->getAttributes ().hasFnAttr (" fpbuiltin-max-error" ))
57
56
return PreservedAnalyses::none ();
58
- StringRef MaxError = II->getAttributes ().getFnAttr (
59
- " fpbuiltin-max-error" ).getValueAsString ();
57
+ StringRef MaxError = II->getAttributes ()
58
+ .getFnAttr (" fpbuiltin-max-error" )
59
+ .getValueAsString ();
60
60
61
61
if (ID == llvm::Intrinsic::fpbuiltin_sqrt) {
62
62
if (MaxError != SQRT_ERROR)
63
63
return PreservedAnalyses::none ();
64
64
WorkListSqrt.push_back (II);
65
- }
66
- else if (ID == llvm::Intrinsic::fpbuiltin_fdiv) {
65
+ } else if (ID == llvm::Intrinsic::fpbuiltin_fdiv) {
67
66
if (MaxError != FDIV_ERROR)
68
67
return PreservedAnalyses::none ();
69
68
WorkListFDiv.push_back (II);
@@ -113,9 +112,9 @@ SYCLSqrtFDivMaxErrorCleanUpPass::run(Module &M,
113
112
Type *Ty = Sqrt->getType ();
114
113
AttributeList Attrs = Sqrt->getAttributes ();
115
114
Function *NewSqrtF =
116
- Intrinsic::getDeclaration (&M, llvm::Intrinsic::sqrt, Ty);
117
- auto *NewSqrt = Builder. CreateCall (NewSqrtF, { Sqrt-> getOperand ( 0 ) },
118
- Sqrt->getName ());
115
+ Intrinsic::getDeclaration (&M, llvm::Intrinsic::sqrt, Ty);
116
+ auto *NewSqrt =
117
+ Builder. CreateCall (NewSqrtF, {Sqrt-> getOperand ( 0 )}, Sqrt->getName ());
119
118
120
119
// Copy FP flags, metadata and attributes. Replace old call with a new call.
121
120
Attrs = Attrs.removeFnAttribute (Sqrt->getContext (), " fpbuiltin-max-error" );
@@ -134,9 +133,8 @@ SYCLSqrtFDivMaxErrorCleanUpPass::run(Module &M,
134
133
DeclToRemove.insert (FDiv->getCalledFunction ());
135
134
IRBuilder Builder (FDiv);
136
135
Builder.SetInsertPoint (FDiv);
137
- Instruction *NewFDiv =
138
- cast<Instruction>(Builder.CreateFDiv (
139
- FDiv->getOperand (0 ), FDiv->getOperand (1 ), FDiv->getName ()));
136
+ Instruction *NewFDiv = cast<Instruction>(Builder.CreateFDiv (
137
+ FDiv->getOperand (0 ), FDiv->getOperand (1 ), FDiv->getName ()));
140
138
141
139
// Copy FP flags and metadata. Replace old call with a new instruction.
142
140
cast<Instruction>(NewFDiv)->copyMetadata (*FDiv);
0 commit comments