[PATCH] D82557: [MSP430][NFC] Remove redundant condition

Balogh, Ádám via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 25 08:01:08 PDT 2020


baloghadamsoftware created this revision.
baloghadamsoftware added a reviewer: asl.
baloghadamsoftware added a project: LLVM.
Herald added subscribers: martong, gamesh411, Szelethus, dkrupp, rnkovacs, hiraditya.

Condition `NumBytes` is checked both in an outer and in an inner `if` statement in `MSP430FrameLowering::emitPrologue()`. This patch removes the redundant inner check.

The issue was found using `clang-tidy` check under review `misc-redundant-condition`. See https://reviews.llvm.org/D81272.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82557

Files:
  llvm/lib/Target/MSP430/MSP430FrameLowering.cpp


Index: llvm/lib/Target/MSP430/MSP430FrameLowering.cpp
===================================================================
--- llvm/lib/Target/MSP430/MSP430FrameLowering.cpp
+++ llvm/lib/Target/MSP430/MSP430FrameLowering.cpp
@@ -92,14 +92,13 @@
     // If there is an ADD16ri or SUB16ri of SP immediately after this
     // instruction, merge the two instructions.
     // mergeSPUpdatesDown(MBB, MBBI, &NumBytes);
+    //if (NumBytes) {
 
-    if (NumBytes) {
-      MachineInstr *MI =
-        BuildMI(MBB, MBBI, DL, TII.get(MSP430::SUB16ri), MSP430::SP)
-        .addReg(MSP430::SP).addImm(NumBytes);
-      // The SRW implicit def is dead.
-      MI->getOperand(3).setIsDead();
-    }
+    MachineInstr *MI =
+      BuildMI(MBB, MBBI, DL, TII.get(MSP430::SUB16ri), MSP430::SP)
+      .addReg(MSP430::SP).addImm(NumBytes);
+    // The SRW implicit def is dead.
+    MI->getOperand(3).setIsDead();
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82557.273360.patch
Type: text/x-patch
Size: 909 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200625/117ed775/attachment.bin>


More information about the llvm-commits mailing list