This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][DAGCombine] Fix a bug in performBuildVectorCombine where it could produce an invalid EXTRACT_SUBVECTOR
ClosedPublic

Authored by mnadeem on Aug 23 2022, 4:59 PM.

Details

Summary

EXTRACT_SUBVECTOR requires that Idx be a constant multiple of ResultType's
known minimum vector length.

Something like this will produce an invalid extract_subvector:

t1: v4i16 = .....
t2: i32 = extract_vector_elt t1, Constant:i64<1>
t3: i32 = extract_vector_elt t1, Constant:i64<2>
t4: v2i32 = BUILD_VECTOR t2, t3
// produces
t5: v2i32 = extract_subvector t...., Constant:i64<1>

Diff Detail

Event Timeline

mnadeem created this revision.Aug 23 2022, 4:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2022, 4:59 PM
mnadeem requested review of this revision.Aug 23 2022, 4:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2022, 4:59 PM
mnadeem updated this revision to Diff 455028.Aug 23 2022, 5:23 PM
fhahn added a subscriber: fhahn.Aug 24 2022, 12:54 AM

Something like this will produce an invalid extract_subvector:

Could you attach a test case?

A test would be nice but otherwise the patch looks good. FYI: I didn't realise this requirement existed for fixed length vectors and it seems SelectionDAG::getNode() is missing the relevant asserts. However, when I add them I'm seeing only non-aarch64 failures, so I'm not going to open that can of worms just yet.

paulwalker-arm accepted this revision.Aug 24 2022, 9:46 AM
This revision is now accepted and ready to land.Aug 24 2022, 9:46 AM
mnadeem updated this revision to Diff 455267.Aug 24 2022, 10:15 AM

Added a reduced test case to check that we don't crash.

Should I go ahead and merge if the test looks okay?

This revision was landed with ongoing or failed builds.Aug 24 2022, 4:25 PM
This revision was automatically updated to reflect the committed changes.