When upgrading cast to bool to a setne, generate icmp ne instead.
authorReid Spencer <rspencer@reidspencer.com>
Sat, 9 Dec 2006 16:56:55 +0000 (16:56 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Sat, 9 Dec 2006 16:56:55 +0000 (16:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32399 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-upgrade/UpgradeParser.y

index f53369d6031bb258e52a96a53e8fcac92e584996..126a37542e686cb4e1d87c433681a4acc2c6de0a 100644 (file)
@@ -194,10 +194,16 @@ static std::string getCastUpgrade(
     // the original intent by replace the cast with a setne
     const char* comparator = SrcTy.isPointer() ? ", null" : 
       (SrcTy.isFloatingPoint() ? ", 0.0" : ", 0");
-    if (isConst) 
-      Result = "setne (" + Source + comparator + ")";
-    else
-      Result = "setne " + Source + comparator;
+#if UPGRADE_SETCOND_OPS 
+    const char* compareOp = SrcTy.isFloatingPoint() ? "setne " : "icmp ne ";
+#else
+    const char* compareOp = "setne";
+#endif
+    if (isConst) { 
+      Result = "(" + Source + comparator + ")";
+      Result = compareOp + Result;
+    } else
+      Result = compareOp + Source + comparator;
     return Result; // skip cast processing below
   }
   ResolveType(SrcTy);