[NFC] Simplify code in IndVars
authorMax Kazantsev <mkazantsev@azul.com>
Fri, 30 Oct 2020 10:37:03 +0000 (17:37 +0700)
committerMax Kazantsev <mkazantsev@azul.com>
Fri, 30 Oct 2020 10:49:32 +0000 (17:49 +0700)
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp

index 729173d..2a5d1da 100644 (file)
@@ -1132,18 +1132,14 @@ bool WidenIV::widenWithVariantUse(NarrowIVDefUse DU) {
   if (!AddRecOp1 || AddRecOp1->getLoop() != L)
     return false;
 
-  if (ExtKind == SignExtended) {
-    for (Use &U : NarrowUse->uses()) {
-      SExtInst *User = dyn_cast<SExtInst>(U.getUser());
-      if (!User || User->getType() != WideType)
-        return false;
-    }
-  } else { // ExtKind == ZeroExtended
-    for (Use &U : NarrowUse->uses()) {
-      ZExtInst *User = dyn_cast<ZExtInst>(U.getUser());
-      if (!User || User->getType() != WideType)
-        return false;
-    }
+  for (Use &U : NarrowUse->uses()) {
+    Instruction *User = nullptr;
+    if (ExtKind == SignExtended)
+      User = dyn_cast<SExtInst>(U.getUser());
+    else
+      User = dyn_cast<ZExtInst>(U.getUser());
+    if (!User || User->getType() != WideType)
+      return false;
   }
 
   LLVM_DEBUG(dbgs() << "Cloning arithmetic IVUser: " << *NarrowUse << "\n");