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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 2 12:22:06 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
----------------
fhahn wrote:

This probably also needs negative tests (including source integer types that != pointer width, only one op is `inttoptr`) and possibly also some cases where `inttoptr` have multiple users?

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


More information about the llvm-commits mailing list