Skip to content

Commit ad9ea64

Browse files
maarquitos14jsji
authored andcommitted
Prevent unnecessary copies. (#2859)
Original commit: KhronosGroup/SPIRV-LLVM-Translator@ac0fc8e190fe890
1 parent ff9380b commit ad9ea64

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,8 @@ SPIRVValue *LLVMToSPIRVBase::transConstantUse(Constant *C,
13381338
Ops = getVec(PtrTy->getId(), Ops);
13391339
}
13401340
}
1341-
return BM->addPtrAccessChainInst(ExpectedType, Ops, nullptr, true);
1341+
return BM->addPtrAccessChainInst(ExpectedType, std::move(Ops), nullptr,
1342+
true);
13421343
}
13431344
}
13441345

@@ -1470,7 +1471,7 @@ SPIRVValue *LLVMToSPIRVBase::transConstant(Value *V) {
14701471
Ops = getVec(PtrTy->getId(), Ops);
14711472
}
14721473
}
1473-
return BM->addPtrAccessChainInst(TranslatedTy, Ops, nullptr,
1474+
return BM->addPtrAccessChainInst(TranslatedTy, std::move(Ops), nullptr,
14741475
GEP->isInBounds());
14751476
}
14761477
auto *Inst = ConstUE->getAsInstruction();
@@ -2564,8 +2565,8 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
25642565
// access chain instructions. Replace return type to do that.
25652566
TranslatedTy = SPVPointerOperand->getType();
25662567

2567-
return mapValue(
2568-
V, BM->addPtrAccessChainInst(TranslatedTy, Ops, BB, GEP->isInBounds()));
2568+
return mapValue(V, BM->addPtrAccessChainInst(TranslatedTy, std::move(Ops),
2569+
BB, GEP->isInBounds()));
25692570
}
25702571

25712572
if (auto *Ext = dyn_cast<ExtractElementInst>(V)) {
@@ -4315,7 +4316,7 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
43154316
Zero = BM->addConstant(ResTy, 0);
43164317
APInt MinusOneValue(ResTy->getIntegerBitWidth(), 0, 1);
43174318
MinusOneValue.setAllBits();
4318-
MinusOne = BM->addConstant(ResTy, MinusOneValue);
4319+
MinusOne = BM->addConstant(ResTy, std::move(MinusOneValue));
43194320
}
43204321

43214322
Op OC1 = (IID == Intrinsic::scmp) ? OpSLessThanEqual : OpULessThanEqual;

0 commit comments

Comments
 (0)