[CodeGenPrepare] Use const reference to avoid unnecessary APInt copy. NFC
authorCraig Topper <craig.topper@sifive.com>
Wed, 11 May 2022 18:52:07 +0000 (11:52 -0700)
committerCraig Topper <craig.topper@sifive.com>
Wed, 11 May 2022 19:06:45 +0000 (12:06 -0700)
Spotted while looking at Matthias' patches.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D124985

llvm/lib/CodeGen/CodeGenPrepare.cpp

index 813fbd1..c91dfd2 100644 (file)
@@ -7021,7 +7021,7 @@ bool CodeGenPrepare::optimizeSwitchType(SwitchInst *SI) {
   ExtInst->setDebugLoc(SI->getDebugLoc());
   SI->setCondition(ExtInst);
   for (auto Case : SI->cases()) {
-    APInt NarrowConst = Case.getCaseValue()->getValue();
+    const APInt &NarrowConst = Case.getCaseValue()->getValue();
     APInt WideConst = (ExtType == Instruction::ZExt) ?
                       NarrowConst.zext(RegWidth) : NarrowConst.sext(RegWidth);
     Case.setValue(ConstantInt::get(Context, WideConst));