[llvm] 73f766c - [RISCV] Remove unnecessary use of IRBuilder from RISCVCodeGenPrepare.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 17 11:06:37 PDT 2022


Author: Craig Topper
Date: 2022-07-17T10:59:54-07:00
New Revision: 73f766ca9a08d570c5831b815902189aa5568f78

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

LOG: [RISCV] Remove unnecessary use of IRBuilder from RISCVCodeGenPrepare.

We're creating single instruction to replace another instruction.
We can insert using the InsertBefore operand of the constructor.
Then copy the debug location.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp b/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp
index 4a3a7786e5e7..469d19f59cef 100644
--- a/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp
+++ b/llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp
@@ -18,7 +18,6 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/CodeGen/TargetPassConfig.h"
-#include "llvm/IR/IRBuilder.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Pass.h"
 
@@ -71,9 +70,9 @@ bool RISCVCodeGenPrepare::optimizeZExt(ZExtInst *ZExt) {
   if (isImpliedByDomCondition(ICmpInst::ICMP_SGE, Src,
                               Constant::getNullValue(Src->getType()), ZExt,
                               *DL)) {
-    IRBuilder<> Builder(ZExt);
-    Value *SExt = Builder.CreateSExt(Src, ZExt->getType());
+    auto *SExt = new SExtInst(Src, ZExt->getType(), "", ZExt);
     SExt->takeName(ZExt);
+    SExt->setDebugLoc(ZExt->getDebugLoc());
 
     ZExt->replaceAllUsesWith(SExt);
     ZExt->eraseFromParent();


        


More information about the llvm-commits mailing list