[PATCH] D144492: [InstCombine] Support multiple comparisons in foldAllocaCmp()

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 20 09:37:33 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:959
+    }
+    case 3:
+      // Both icmp operands are based on the alloca, so this is comparing
----------------
You could add a todo here for some simplifications i.e
```
define i1 @foo(i64 %x) {
  %alloc = alloca i64, i64 8
  %p = getelementptr i64, ptr %alloc, i64 %x
  %q = getelementptr i64, ptr %alloc, i64 3
  %cmp = icmp eq ptr %p, %q
  ret i1 %cmp
}
```

is really `icmp eq i64 %x, 3`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144492/new/

https://reviews.llvm.org/D144492



More information about the llvm-commits mailing list