This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Fold insert_subvector undef, (extract_subvector X, 0), 0 with non-matching types
ClosedPublic

Authored by reames on Aug 17 2023, 11:26 AM.

Details

Summary

We have an existing DAG combine for when an insert/extract subvector pair is entirely a nop, but we hadn't handled the case where the net result was either an insert or an extract (but not both). The transform is restricted to index = 0 to avoid having to adjust indices after the transform.

Reviews, a couple comments on the test changes:

  • Mostly RISCV, mostly schedule reordering.
  • One real regression in splats-with-mixed-vl.ll due to a different overly aggressive combine, fix in a follow up patch.
  • The test/CodeGen/X86/vector-replicaton-i1-mask.ll diff looked concerning at first, but not the mask size at most 4 i1s. I think the type changes on the mask loads are correct, but would welcome a second opinion with someone more familiar with AVX512 codegen.

Diff Detail

Event Timeline

reames created this revision.Aug 17 2023, 11:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2023, 11:26 AM
reames requested review of this revision.Aug 17 2023, 11:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2023, 11:26 AM
RKSimon added inline comments.Aug 18 2023, 7:41 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
25610

isNullConstant(N2)

reames updated this revision to Diff 551519.Aug 18 2023, 8:11 AM

Address review comment.

The (trivial) X86 changes LGTM - but a RISCV expert should review the RVV changes (with D158202)

LGTM other than the extra period.

The other comment can be addressed in a future patch.

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
25601

Extra period at the end.

llvm/test/CodeGen/RISCV/rvv/extract-subvector.ll
472

This test case could be a single slidedown. Probably needs a special version of concat_vectors lowering. The rules on extract_subvector indices forced type legalization to make a concat of 3 extract_subvectors that are contiguous.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 18 2023, 11:59 AM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
craig.topper reopened this revision.Aug 18 2023, 12:00 PM

Accidentally committed this after I applied locally to experiment.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 18 2023, 12:39 PM
This revision was automatically updated to reflect the committed changes.
llvm/test/CodeGen/X86/pr34177.ll