This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] try to move bitcast after extract_subvector
ClosedPublic

Authored by spatel on May 10 2019, 2:58 PM.

Details

Summary

I noticed that we were failing to narrow an x86 ymm math op in a case similar to the 'madd' test diff. That is because a bitcast is sitting between the math and the extract subvector and thwarting our pattern matching for narrowing:

     t56: v8i32 = add t59, t58
    t68: v4i64 = bitcast t56
  t73: v2i64 = extract_subvector t68, Constant:i64<2>
t96: v4i32 = bitcast t73

There are a few wins and neutral diffs in the other tests.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel created this revision.May 10 2019, 2:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 10 2019, 2:58 PM
RKSimon added inline comments.May 11 2019, 9:09 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
17595 ↗(On Diff #199087)

Its typically safer to do (SrcNumElts % DestNumElts) == 0

llvm/test/CodeGen/X86/sad.ll
1452 ↗(On Diff #199087)

weird - if this is all xmm code now why hasn't the vzeroupper gone?

spatel marked an inline comment as done.May 12 2019, 6:09 AM
spatel added inline comments.
llvm/test/CodeGen/X86/sad.ll
1452 ↗(On Diff #199087)

There seem to be several potential missed opportunities to squash this, but we have the following heading into isel:

      t142: v4i32 = scalar_to_vector Constant:i32<1>
    t143: v8i32 = insert_subvector undef:v8i32, t142, Constant:i64<0>
  t141: v8i32 = X86ISD::VZEXT_MOVL t143
t178: v4i32 = extract_subvector t141, Constant:i64<0>
spatel updated this revision to Diff 199167.May 12 2019, 6:12 AM
spatel marked an inline comment as done.

Patch updated:
Use modulo of element counts for safety.

RKSimon accepted this revision.May 12 2019, 6:29 AM

LGTM - cheers.

llvm/test/CodeGen/X86/sad.ll
1452 ↗(On Diff #199087)

Thanks for checking - that should be easy enough to fix.

This revision is now accepted and ready to land.May 12 2019, 6:29 AM
This revision was automatically updated to reflect the committed changes.