Page MenuHomePhabricator

[SDAG] Do not convert undef to 0 when folding CONCAT/BUILD_VECTOR

Authored by kparzysz on Thu, Sep 24, 6:23 PM.



When calling DAG.getNode(ISD::CONCAT_VECTOR, ...) with arguments that are BUILD_VECTOR and/or undef, the DAG will try to fold it into one large BUILD_VECTOR. In the process of preparing the operands, it may perform sign- or zero-extension of all values having width less than the required one. This includes undefs, which causes them to become zeros. This conversion from undef to "def" is not necessary and may inhibit further optimizations.

Concrete example: the original code had this operation in it:

v8i8 = BUILD_VECTOR t109, t109, t109, t109, t109, t109, t109, undef:i32

The operands were all of a legal type i32, i8 as a scalar is not legal on this target. The vector was then widened to v128i8 by concatenating it with a number of undef vectors. The folding described above broke up all these undef vectors into individual elements, and extended them to i32, which resulted in (unnecessarily) appending a number of 0s instead.

Diff Detail

Event Timeline

kparzysz created this revision.Thu, Sep 24, 6:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptThu, Sep 24, 6:23 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
kparzysz requested review of this revision.Thu, Sep 24, 6:23 PM
This revision is now accepted and ready to land.Mon, Sep 28, 9:36 PM
kparzysz closed this revision.Wed, Sep 30, 6:46 AM

Committed in db04bec5f1eeb581ee1470e5f444cc7b918c6d93. Somehow phabricator missed it and didn't close automatically.