This is an archive of the discontinued LLVM Phabricator instance.

[X86] Don't create i64 constants on 32-bit targets when lowering v64i1 constant build vectors
ClosedPublic

Authored by craig.topper on Sep 14 2017, 12:20 PM.

Details

Summary

When handling a v64i1 build vector of constants on 32-bit targets we were creating an illegal i64 constant that we then bitcasted back to v64i1. We need to instead create two 32-bit constants, bitcast them to v32i1 and concat the result. We should also take care to handle the halves being all zeros/ones after the split.

This patch splits the build vector and then recursively lowers the two pieces. This allows us to handle the all ones and all zeros cases with minimal effort. Ideally we'd just do the split and concat, and let lowering get called again on the new nodes, but getNode has special handling for CONCAT_VECTORS that reassembles the pieces back into a single BUILD_VECTOR. Hopefully the two temporary BUILD_VECTORS we had to create to do this that don't get returned don't cause any issues.

Fixes PR34605.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Sep 14 2017, 12:20 PM
RKSimon accepted this revision.Sep 15 2017, 3:17 AM

LGTM with some minor observations.

lib/Target/X86/X86ISelLowering.cpp
7029 ↗(On Diff #115257)

Not sure if it'll work but can you re-use LowerVectorIntUnary to do this? We seem to have a lot of 'split+2*op+concat' patterns/helpers.

test/CodeGen/X86/pr34605.ll
4 ↗(On Diff #115257)

Is this used in the test? I couldn't see it.

6 ↗(On Diff #115257)

Is %len used in the test? I couldn't see it.

This revision is now accepted and ready to land.Sep 15 2017, 3:17 AM
craig.topper added inline comments.Sep 15 2017, 9:58 AM
lib/Target/X86/X86ISelLowering.cpp
7029 ↗(On Diff #115257)

I think that will also end up calling getNode with a CONCAT_VECTOR of two BUILD_VECTORS. Since extractSubvector knows to look through BUILD_VECTORS.

test/CodeGen/X86/pr34605.ll
4 ↗(On Diff #115257)

Removed.

6 ↗(On Diff #115257)

Removed

RKSimon added inline comments.Sep 15 2017, 10:05 AM
lib/Target/X86/X86ISelLowering.cpp
7029 ↗(On Diff #115257)

OK, no worries

This revision was automatically updated to reflect the committed changes.