[PATCH] D108408: [InstCombine] Transform X == 0 ? 0 : X * Y --> X * freeze(Y).
Filipp Zhinkin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 21 03:17:07 PDT 2021
fzhinkin added a comment.
In D108408#2958323 <https://reviews.llvm.org/D108408#2958323>, @lebedev.ri wrote:
> 1. what's wrong with vectors?
There's nothing wrong, I'll support it, thanks!
> 2. can't we preserve no-wrap flags?
Definitely.
> 3. for vectors, what if some element is not zero but undef? (see ` Constant::mergeUndefsWith()`)
Not sure that I fully understand the issue.
If `%a` in the snippet below contains some undefs then the select may choose either `0` or `%m` depending on particular value of `a` (which could be `0` for undef elements).
Probably `%a` should be frozen to ensure that both `icmp` and `mul` will see the same `a`'s value, but (if I understood it correctly) absence of `freeze` does not compromise the correctness.
define <2 x i4> @src(<2 x i4> %a, <2 x i4> %b) {
%c = icmp eq <2 x i4> %a, zeroinitializer
%m = mul <2 x i4> %a, %b
%r = select <2 x i1> %c, <2 x i4> zeroinitializer, <2 x i4> %m
ret <2 x i4> %r
}
Or you meant that the code could be folded even if `icmp`'s RHS is not only the all-zeros vector, but a constant-vector containing some undefs?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108408/new/
https://reviews.llvm.org/D108408
More information about the llvm-commits
mailing list