[PATCH] D42090: [DAGCombiner] Add a DAG combine to turn a splat build_vector where the splat elemnt is a bitcast from a vector type into a concat_vector
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 17 07:12:11 PST 2018
spatel added inline comments.
================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:14952
+ // concat_vector.
+ if (SDValue Splat = cast<BuildVectorSDNode>(N)->getSplatValue()) {
+ if (Splat.getOpcode() == ISD::BITCAST) {
----------------
RKSimon wrote:
> Also, should this be limited to before LegalOperations in case a backend is trying to do this in reverse?
That sounds right. I think this is wrong frequently, but nobody notices because it's not exposed in regression tests for in-tree targets. Another option - if we do want to run this after legalization - would be to check if the CONCAT is legal or custom before creating it?
================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:14950-14951
+ // If this is a splat of a bitcast from another vector, change to a
+ // concat_vector.
+ if (SDValue Splat = cast<BuildVectorSDNode>(N)->getSplatValue()) {
----------------
Add a formula in the comment to describe the transform?
build_vector [ bitcast (Splat0), bitcast (Splat0), ...] --> bitcast (concat_vectors Splat0)
================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:14953
+ if (SDValue Splat = cast<BuildVectorSDNode>(N)->getSplatValue()) {
+ if (Splat.getOpcode() == ISD::BITCAST) {
+ EVT SrcVT = Splat.getOperand(0).getValueType();
----------------
Might want to use 'peekThroughBitcast' here...although that reminds me that I still need to figure out if we can remove the loop in there yet.
https://reviews.llvm.org/D42090
More information about the llvm-commits
mailing list