fold vecreduce_or/and(splat_vector(val)) -> constant val
fold vecreduce_xor(splat_vector(val)) -> constant zero
Precommit tests D132207
Differential D132206
[DAGCombiner] Fold vecreduce_xor/or/and(splat_vector(val)) to constant Jimerlife on Aug 19 2022, 12:03 AM. Authored by
Details
Diff Detail
Event TimelineComment Actions XOR will be 0 or val depending on if there are an even number of vector elements. Can you add some tests for both cases? Comment Actions Do you have real world examples of C code where this occurs? Would this be better to do in InstCombine? Where are the test deltas?
Comment Actions I have no real world examples of C code, just think could fold this. I am not sure if this is better to do in InstCombine. I create precommit tests D132207, but this test does't consider vector element count. Element count should also be consider. Comment Actions This might be more useful if you did it in SelectionDAG::computeKnownBits - then it'd work for any case with common bits in every vector element and you'd get constant folding as well. Comment Actions Hi @Jimerlife, I think it's common practice to create a chain of patches in your downstream repo where the code change patch is based off the pre-committed test patch. That way we can observe the change in behaviour as part of this patch without having to wait for a rebase. You can edit the parent revision to add the pre-commit as a parent so the chain is clear in Phabricator. |
What if the element count is odd?