[PATCH] D55274: [DagCombiner][X86] Simplify a ConcatVectors of a scalar_to_vector with undef.

Andrea Di Biagio via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 5 07:37:23 PST 2018


andreadb updated this revision to Diff 176813.
andreadb marked an inline comment as done.
andreadb added a comment.

Thanks Simon for the feedback.
My new combine logic was indeed very similar to the existing logic in visitCONCAT_VECTORS.
This patch reuses that logic and introduces a new rule for the case where the first operand of the concat_vector is a scalar_to_vector.

For readability reasons (and simplicity), i moved all of that logic from `visitCONCAT_VECTORS` into a separate function.

The reason why I had to tweak `combineConcatVectorOfScalars()` is because before this patch, `visitCONCAT_VECTORS` used to early exit from `visitCONCAT_VECTORS` if it failed to fold a 'concat_vectors of a scalar'. 
With this patch, we don't bail out immediately from `visitCONCAT_VECTORS`. Instead, we try other combine rules. As a consequence, we potentially end up calling function `combineConcatVectorOfScalars()` more often.
The problem with running `combineConcatVectorOfScalars()`  more often is that there are cases where `combineConcatVectorOfScalars()` returns a sub-optimal `BUILD_VECTOR(Scalar, UNDEF)`, insted of a much simpler (and more canonical) `SCALAR_TO_VECTOR(Scalar)`.
That particular build_vector is poorly lowered by the x86 backend if the target only has SSE but not SSE2. So, test `codegen/x86/vec_fneg.ll` was reporting a failure after that refactoring (using -mtriple=i686 -mattr=+sse). Fixing that particular corner case was enough to get back the "expected codegen".


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55274/new/

https://reviews.llvm.org/D55274

Files:
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  test/CodeGen/X86/combine-concatvectors.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55274.176813.patch
Type: text/x-patch
Size: 6540 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181205/eb3e93a1/attachment.bin>


More information about the llvm-commits mailing list