[PATCH] D142687: [Local] Don't keep K's range even if K dominates J

luxufan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 22 23:58:07 PDT 2023


StephenFan added inline comments.


================
Comment at: llvm/test/Transforms/GVN/range.ll:109
+define i32 @load_noundef_load(ptr %p) {
+; CHECK-LABEL: define i32 @load_noundef_load
+; CHECK-SAME: (ptr [[P:%.*]]) {
----------------
Now, this case is combined into the most generic range. But I think it is unnecessary.
Before transforming, there are 4 cases:
1. Both are satisfied. Return a well-defined value.
2. Both are violated. IUB.
3. `!0` is violated and `!1` is satisfied. IUB.
4. `!0` is satisfied and `!1` is violated. Return a poison value.

If we don't combine them into the most generic range and just retain `!0`.
1. Both are satisfied. Return a well-defined value.
2. Both are violated. IUB.
3. `!0` is violated and `!1` is satisfied. IUB.
4. `!0` is satisfied and `!1` is violated. Return a well-defined value.
The only difference is case 4. We transform returning a poison value to returning a well-defined value. But it is safe.

In summary, I think we don't need to combine them into the most generic range for this case, just retaining it is enough.
Do you agree with me @nikic?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142687



More information about the llvm-commits mailing list