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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 23 03:47:14 PDT 2023


nikic added inline comments.


================
Comment at: llvm/test/Transforms/GVN/range.ll:121
+
+define i32 @load_load_noundef(ptr %p) {
+; CHECK-LABEL: define i32 @load_load_noundef
----------------
StephenFan wrote:
> @nikic Why do we need to use the generic range here?
> 
> 1. Both are satisfied. Return a well-defined value.
> 2. Both are violated, IUB
> 3. !0 is satisified, !1 is violated. IUB.
> 4. !0 is violated, !1 is satisified. return a poison value.
> If we retain `!0`:
> 1. Both are satisfied. Return a well-defined value.
> 2. Both are violated. Return a poison value.
> 3. !0 is satisfied, !1 is violated. Return a well-defined value
> 4. !0 is violated, !1 is satisfied. Return a poison value.
> 
> The differences are in case 2 and case 3. In case 2, transforming from IUB to return a poison value is safe. In case 3, transforming from IUB to return a poison value is also safe. Or do I misunderstand something?
You need to assume that the example is simplified, and what actually happens is that `%a` is never used (dynamically dead). In that case if `!0` is violated but `!1` is satisfied, this would return a poison value for `%b`, which is incorrect.

It's okay in this specific code sample (where both values are fed into the same operation), but this is not the point of these tests.


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