This is an archive of the discontinued LLVM Phabricator instance.

[X86] When legalizing (v64i1 select i8, v64i1, v64i1) make sure not to introduce bitcasts to i64 in 32-bit mode
ClosedPublic

Authored by craig.topper on Jan 16 2018, 5:25 PM.

Details

Summary

We legalize selects of masks with scalar conditions using a bitcast to an integer type. But if we are in 32-bit mode we can't convert v64i1 to i64. So instead split the v64i1 to v32i1 and concat it back together. Each half will then be legalized by bitcasting to i32 which is fine.

The test case is a little indirect. If we have the v64i1 select in IR it will get legalized by legalize vector ops which has a run of type legalization after it. That type legalization run is able to fix this i64 bitcast. So in order to avoid that we need a build_vector of a splat which legalize vector ops will ignore. Legalize DAG will then turn that into a select via LowerBUILD_VECTORvXi1. And the select will get legalized. In this case there is no type legalizer run to cleanup the bitcast.

This fixes pr35972.

Diff Detail

Event Timeline

craig.topper created this revision.Jan 16 2018, 5:25 PM
RKSimon accepted this revision.Jan 17 2018, 9:41 AM

LGTM

This revision is now accepted and ready to land.Jan 17 2018, 9:41 AM