[PATCH] D36247: [LVI] Constant-propagate a zero extension of the switch condition value through case edges
Sanjoy Das via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 2 17:40:04 PDT 2017
sanjoy added a comment.
Code wise this looks correct to me, but I'd prefer to phrase the solution a bit differently in the commit message and in the comments: IIUC the bug we had was that we were assuming `Condition != T` (in the default block) implied `f(Condition) != f(T)`. However this isn't true for a non injective `f` (like `f(i32 x) = and i32 x, 2`).
For instance we //could// still do this transformation for
x = cond + 2
switch cond, label %left, [ i32 20, label %right]
left:
...
right:
...
In `left` we know that `cond` is not `20` and thus `x` is not `22`, since `f(x) = x + 2` is injective.
(I'm not suggesting we actually do the above btw, I think the case this patch is handling (`f(x) = x`) is enough for now.)
================
Comment at: lib/Analysis/LazyValueInfo.cpp:158
+ }
+ return Optional<APInt>();
+ }
----------------
Can you `return None;` here?
================
Comment at: test/Transforms/CorrelatedValuePropagation/range.ll:587
+ i64 4, label %exit2
+ ]
+
----------------
Can we demonstrate the issue with just one `switch`?
https://reviews.llvm.org/D36247
More information about the llvm-commits
mailing list