[llvm] [InstSimplify] Implement simple folds for `ucmp`/`scmp` intrinsics (PR #95601)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 14:44:51 PDT 2024


================
@@ -6505,6 +6505,33 @@ Value *llvm::simplifyBinaryIntrinsic(Intrinsic::ID IID, Type *ReturnType,
 
     break;
   }
+  case Intrinsic::scmp:
+  case Intrinsic::ucmp: {
+    // Fold cmp x, x -> 0
+    if (Op0 == Op1)
+      return Constant::getNullValue(ReturnType);
----------------
Poseydon42 wrote:

Yeah, I kept it there because I assumed that `isICmpTrue` would be much slower than just comparing two pointers, even if `isICmpTrue` has this fast path as well, just burried a few calls deep.

https://github.com/llvm/llvm-project/pull/95601


More information about the llvm-commits mailing list