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

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 26 16:08:29 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:938
+        auto Res = ICmps.insert({ICmp, 0});
+        Res.first->second |= 1u << U->getOperandNo();
         return false;
----------------
Why does something like:
```
target datalayout = "p:32:32"
@gp = global ptr null, align 8
declare ptr @hidden_inttoptr()
declare void @witness(i1, i1)
define void @src() {
  %m = alloca i8, i32 4
  %lgp = load ptr, ptr @gp, align 8
  %rhs2 = call ptr @hidden_inttoptr()
  %cmp1 = icmp eq ptr %m, %rhs2
  %cmp2 = icmp eq ptr %lgp, %m
  call void @witness(i1 %cmp1, i1 %cmp2)
  ret void
}
```

Work? Isn't `%m` on both sides? (Although it is fine to reduce this snippet), just dont understand what `U->getOperandNo()` is actually checking for.


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

https://reviews.llvm.org/D144492



More information about the llvm-commits mailing list