Don't use Optional::hasValue (NFC)

This patch replaces x.hasValue() with x where x is contextually
convertible to bool.

GitOrigin-RevId: 94460f513654da2ee6e759db2804e73001818de5
diff --git a/lib/Transform/ManualOptimizer.cpp b/lib/Transform/ManualOptimizer.cpp
index ef705ec..640ae0a 100644
--- a/lib/Transform/ManualOptimizer.cpp
+++ b/lib/Transform/ManualOptimizer.cpp
@@ -42,7 +42,7 @@
 
   Optional<int> Count =
       getOptionalIntLoopAttribute(LoopID, "llvm.loop.unroll.count");
-  if (Count.hasValue())
+  if (Count)
     return Count.getValue() == 1 ? TM_SuppressedByUser : TM_ForcedByUser;
 
   if (getBooleanLoopAttribute(LoopID, "llvm.loop.unroll.enable"))
diff --git a/lib/Transform/MatmulOptimizer.cpp b/lib/Transform/MatmulOptimizer.cpp
index 4a40fac..bad05df 100644
--- a/lib/Transform/MatmulOptimizer.cpp
+++ b/lib/Transform/MatmulOptimizer.cpp
@@ -570,19 +570,19 @@
   auto L1DCache = llvm::TargetTransformInfo::CacheLevel::L1D;
   auto L2DCache = llvm::TargetTransformInfo::CacheLevel::L2D;
   if (FirstCacheLevelSize == -1) {
-    if (TTI->getCacheSize(L1DCache).hasValue())
+    if (TTI->getCacheSize(L1DCache))
       FirstCacheLevelSize = TTI->getCacheSize(L1DCache).getValue();
     else
       FirstCacheLevelSize = static_cast<int>(FirstCacheLevelDefaultSize);
   }
   if (SecondCacheLevelSize == -1) {
-    if (TTI->getCacheSize(L2DCache).hasValue())
+    if (TTI->getCacheSize(L2DCache))
       SecondCacheLevelSize = TTI->getCacheSize(L2DCache).getValue();
     else
       SecondCacheLevelSize = static_cast<int>(SecondCacheLevelDefaultSize);
   }
   if (FirstCacheLevelAssociativity == -1) {
-    if (TTI->getCacheAssociativity(L1DCache).hasValue())
+    if (TTI->getCacheAssociativity(L1DCache))
       FirstCacheLevelAssociativity =
           TTI->getCacheAssociativity(L1DCache).getValue();
     else
@@ -590,7 +590,7 @@
           static_cast<int>(FirstCacheLevelDefaultAssociativity);
   }
   if (SecondCacheLevelAssociativity == -1) {
-    if (TTI->getCacheAssociativity(L2DCache).hasValue())
+    if (TTI->getCacheAssociativity(L2DCache))
       SecondCacheLevelAssociativity =
           TTI->getCacheAssociativity(L2DCache).getValue();
     else