[PATCH] D153963: [InstCombine] Fold binop of select and cast of select condition
Antonio Frighetto via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 10 08:28:33 PDT 2023
antoniofrighetto added a comment.
In D153963#4482931 <https://reviews.llvm.org/D153963#4482931>, @goldstein.w.n wrote:
> So I'm going to propose something slightly different for accomplishing this patch.
> Instead of making a combine for binops, I think you can just arbitrarily
> constant propagate any usage of `cond` to the true/false arms.
I guess with `TrueVal->Operands()` we actually mean the (unique) user of `TrueVal`? I'm not exactly following how we would benefit from this, where the operands of the select are Values in most of our use cases, here's just an example:
define i64 @src(i1 %c) {
%sel = select i1 %c, i64 64, i64 1
%ext = zext i1 %c to i64
%add = add i64 %sel, %ext
ret i64 %add
}
Conversely, wouldn't the proposed change be trying to catch the following orthogonal test case?
define i64 @src(i1 %c, i64 %a, i64 %b, i64 %d) {
%ext = zext i1 %c to i64
%add = add i64 %a, %ext
%sub = sub i64 %b, %ext
%sel = select i1 %c, i64 %add, i64 %sub
ret i64 %sel
}
Where `%add` and `%sub` may be optimized respectively with `%1 = add i64 %a, 1` and `%2 = sub i64 %b, 0`.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153963/new/
https://reviews.llvm.org/D153963
More information about the llvm-commits
mailing list