[llvm] edbf390 - [CodeGenPrepare] Use const reference to avoid unnecessary APInt copy. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed May 11 12:08:11 PDT 2022


Author: Craig Topper
Date: 2022-05-11T12:06:45-07:00
New Revision: edbf390d10b86962774c920cfab089fa1fd1c3f5

URL: https://github.com/llvm/llvm-project/commit/edbf390d10b86962774c920cfab089fa1fd1c3f5
DIFF: https://github.com/llvm/llvm-project/commit/edbf390d10b86962774c920cfab089fa1fd1c3f5.diff

LOG: [CodeGenPrepare] Use const reference to avoid unnecessary APInt copy. NFC

Spotted while looking at Matthias' patches.

Reviewed By: RKSimon

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

Added: 
    

Modified: 
    llvm/lib/CodeGen/CodeGenPrepare.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 813fbd1956f94..c91dfd254a651 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -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));


        


More information about the llvm-commits mailing list