@@ -1146,24 +1146,24 @@ class LowerMatrixIntrinsics {
1146
1146
Value *Op1;
1147
1147
Value *Op2;
1148
1148
MatrixTy Result;
1149
+ IRBuilder<> Builder (Inst);
1149
1150
if (auto *BinOp = dyn_cast<BinaryOperator>(Inst))
1150
- Result = VisitBinaryOperator (BinOp, SI);
1151
+ Result = VisitBinaryOperator (BinOp, SI, Builder );
1151
1152
else if (auto *Cast = dyn_cast<CastInst>(Inst))
1152
- Result = VisitCastInstruction (Cast, SI);
1153
+ Result = VisitCastInstruction (Cast, SI, Builder );
1153
1154
else if (auto *UnOp = dyn_cast<UnaryOperator>(Inst))
1154
- Result = VisitUnaryOperator (UnOp, SI);
1155
+ Result = VisitUnaryOperator (UnOp, SI, Builder );
1155
1156
else if (auto *Intr = dyn_cast<IntrinsicInst>(Inst))
1156
- Result = VisitIntrinsicInst (Intr, SI);
1157
+ Result = VisitIntrinsicInst (Intr, SI, Builder );
1157
1158
else if (auto *Select = dyn_cast<SelectInst>(Inst))
1158
- Result = VisitSelectInst (Select, SI);
1159
+ Result = VisitSelectInst (Select, SI, Builder );
1159
1160
else if (match (Inst, m_Load (m_Value (Op1))))
1160
- Result = VisitLoad (cast<LoadInst>(Inst), SI, Op1);
1161
+ Result = VisitLoad (cast<LoadInst>(Inst), SI, Op1, Builder );
1161
1162
else if (match (Inst, m_Store (m_Value (Op1), m_Value (Op2))))
1162
- Result = VisitStore (cast<StoreInst>(Inst), SI, Op1, Op2);
1163
+ Result = VisitStore (cast<StoreInst>(Inst), SI, Op1, Op2, Builder );
1163
1164
else
1164
1165
continue ;
1165
1166
1166
- IRBuilder<> Builder (Inst);
1167
1167
finalizeLowering (Inst, Result, Builder);
1168
1168
Changed = true ;
1169
1169
}
@@ -1204,7 +1204,8 @@ class LowerMatrixIntrinsics {
1204
1204
}
1205
1205
1206
1206
// / Replace intrinsic calls.
1207
- MatrixTy VisitIntrinsicInst (IntrinsicInst *Inst, const ShapeInfo &SI) {
1207
+ MatrixTy VisitIntrinsicInst (IntrinsicInst *Inst, const ShapeInfo &SI,
1208
+ IRBuilder<> &Builder) {
1208
1209
assert (Inst->getCalledFunction () &&
1209
1210
Inst->getCalledFunction ()->isIntrinsic ());
1210
1211
@@ -1219,7 +1220,6 @@ class LowerMatrixIntrinsics {
1219
1220
return LowerColumnMajorStore (Inst);
1220
1221
case Intrinsic::abs:
1221
1222
case Intrinsic::fabs: {
1222
- IRBuilder<> Builder (Inst);
1223
1223
MatrixTy Result;
1224
1224
MatrixTy M = getMatrix (Inst->getOperand (0 ), SI, Builder);
1225
1225
Builder.setFastMathFlags (getFastMathFlags (Inst));
@@ -1298,7 +1298,6 @@ class LowerMatrixIntrinsics {
1298
1298
ShapeInfo MatrixShape, Value *I, Value *J,
1299
1299
ShapeInfo ResultShape, Type *EltTy,
1300
1300
IRBuilder<> &Builder) {
1301
-
1302
1301
Value *Offset = Builder.CreateAdd (
1303
1302
Builder.CreateMul (J, Builder.getInt64 (MatrixShape.getStride ())), I);
1304
1303
@@ -2228,26 +2227,24 @@ class LowerMatrixIntrinsics {
2228
2227
}
2229
2228
2230
2229
// / Lower load instructions.
2231
- MatrixTy VisitLoad (LoadInst *Inst, const ShapeInfo &SI, Value *Ptr) {
2232
- IRBuilder<> Builder (Inst);
2230
+ MatrixTy VisitLoad (LoadInst *Inst, const ShapeInfo &SI, Value *Ptr,
2231
+ IRBuilder<> & Builder) {
2233
2232
return LowerLoad (Inst, Ptr, Inst->getAlign (),
2234
2233
Builder.getInt64 (SI.getStride ()), Inst->isVolatile (), SI);
2235
2234
}
2236
2235
2237
2236
MatrixTy VisitStore (StoreInst *Inst, const ShapeInfo &SI, Value *StoredVal,
2238
- Value *Ptr) {
2239
- IRBuilder<> Builder (Inst);
2237
+ Value *Ptr, IRBuilder<> &Builder) {
2240
2238
return LowerStore (Inst, StoredVal, Ptr, Inst->getAlign (),
2241
2239
Builder.getInt64 (SI.getStride ()), Inst->isVolatile (), SI);
2242
2240
}
2243
2241
2244
2242
// / Lower binary operators.
2245
- MatrixTy VisitBinaryOperator (BinaryOperator *Inst, const ShapeInfo &SI) {
2243
+ MatrixTy VisitBinaryOperator (BinaryOperator *Inst, const ShapeInfo &SI,
2244
+ IRBuilder<> &Builder) {
2246
2245
Value *Lhs = Inst->getOperand (0 );
2247
2246
Value *Rhs = Inst->getOperand (1 );
2248
2247
2249
- IRBuilder<> Builder (Inst);
2250
-
2251
2248
MatrixTy Result;
2252
2249
MatrixTy A = getMatrix (Lhs, SI, Builder);
2253
2250
MatrixTy B = getMatrix (Rhs, SI, Builder);
@@ -2265,11 +2262,10 @@ class LowerMatrixIntrinsics {
2265
2262
}
2266
2263
2267
2264
// / Lower unary operators.
2268
- MatrixTy VisitUnaryOperator (UnaryOperator *Inst, const ShapeInfo &SI) {
2265
+ MatrixTy VisitUnaryOperator (UnaryOperator *Inst, const ShapeInfo &SI,
2266
+ IRBuilder<> &Builder) {
2269
2267
Value *Op = Inst->getOperand (0 );
2270
2268
2271
- IRBuilder<> Builder (Inst);
2272
-
2273
2269
MatrixTy Result;
2274
2270
MatrixTy M = getMatrix (Op, SI, Builder);
2275
2271
@@ -2293,11 +2289,10 @@ class LowerMatrixIntrinsics {
2293
2289
}
2294
2290
2295
2291
// / Lower cast instructions.
2296
- MatrixTy VisitCastInstruction (CastInst *Inst, const ShapeInfo &Shape) {
2292
+ MatrixTy VisitCastInstruction (CastInst *Inst, const ShapeInfo &Shape,
2293
+ IRBuilder<> &Builder) {
2297
2294
Value *Op = Inst->getOperand (0 );
2298
2295
2299
- IRBuilder<> Builder (Inst);
2300
-
2301
2296
MatrixTy Result;
2302
2297
MatrixTy M = getMatrix (Op, Shape, Builder);
2303
2298
@@ -2315,13 +2310,12 @@ class LowerMatrixIntrinsics {
2315
2310
}
2316
2311
2317
2312
// / Lower selects.
2318
- MatrixTy VisitSelectInst (SelectInst *Inst, const ShapeInfo &Shape) {
2313
+ MatrixTy VisitSelectInst (SelectInst *Inst, const ShapeInfo &Shape,
2314
+ IRBuilder<> &Builder) {
2319
2315
Value *Cond = Inst->getOperand (0 );
2320
2316
Value *OpA = Inst->getOperand (1 );
2321
2317
Value *OpB = Inst->getOperand (2 );
2322
2318
2323
- IRBuilder<> Builder (Inst);
2324
-
2325
2319
MatrixTy Result;
2326
2320
MatrixTy A = getMatrix (OpA, Shape, Builder);
2327
2321
MatrixTy B = getMatrix (OpB, Shape, Builder);
0 commit comments