[llvm] [InstCombine] Compare `icmp inttoptr, inttoptr` values directly (PR #107012)

Marina Taylor via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 2 12:40:40 PDT 2024


================
@@ -5326,3 +5326,22 @@ define i1 @pr94897(i32 range(i32 -2147483648, 0) %x) {
   %cmp = icmp ugt i32 %shl, -50331648
   ret i1 %cmp
 }
+
+define i1 @test_icmp_inttoptr(i64 %x, i64 %y) {
+; CHECK-LABEL: @test_icmp_inttoptr(
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i64 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret i1 [[CMP]]
+  %xptr = inttoptr i64 %x to ptr
----------------
citymarina wrote:

Good point about the multiple users. Regarding the varying integer widths, I had tried writing such tests but the values ended up getting a `trunc` or `zext` to pointer width anyway, so they still passed through this code.

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


More information about the llvm-commits mailing list