[PATCH] D11239: [LoopUnswitch] Add an else clause to IsTrivialUnswitchCondition() when checking HeaderTerm instruction type

Chen Li meloli87 at gmail.com
Wed Jul 15 13:49:51 PDT 2015


chenli created this revision.
chenli added a reviewer: reames.
chenli added a subscriber: llvm-commits.

This is a trivial code change with no functionality effect. 

When LoopUnswitch determines trivial unswitch condition, it checks whether the loop header's terminator instruction is a branch instruction or switch instruction since trivial unswitch condition can only apply to these two instruction types. The current code does not fail the check directly on other instruction types, but check the nullness of LoopExitBB variable instead. The added else clause makes the check fail immediately on other instruction types and makes the code more obvious.  

http://reviews.llvm.org/D11239

Files:
  lib/Transforms/Scalar/LoopUnswitch.cpp

Index: lib/Transforms/Scalar/LoopUnswitch.cpp
===================================================================
--- lib/Transforms/Scalar/LoopUnswitch.cpp
+++ lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -641,6 +641,10 @@
         break;
       }
     }
+  } else {
+    // TrivialUnswitchCondition can only apply to BranchInst or SwitchInst.
+    // Anything else should return false immediately.
+    return false;
   }
 
   // If we didn't find a single unique LoopExit block, or if the loop exit block


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11239.29822.patch
Type: text/x-patch
Size: 505 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150715/010cee3d/attachment.bin>


More information about the llvm-commits mailing list