If we're going to canonicalize IR towards select of constants, try harder to create those.
Also, don't lose the metadata.
Details
Diff Detail
Event Timeline
lib/Transforms/InstCombine/InstCombineSelect.cpp | ||
---|---|---|
966 | Why aren't you using the Builder here? Is it to avoid an implicit fold by the CreateSelect? And I guess that if you use the Builder, then you won't need to explicitly copyMetadata? Or is that missing from the optimization involving the trunc. There was not a single explicit copyMetadata in this file until now. |
lib/Transforms/InstCombine/InstCombineSelect.cpp | ||
---|---|---|
966 | The code added is in the style of the rest of InstCombine. The builder is used for intermediate instructions but not the final instruction which is RAUW. This has to do with the particular behavior InstCombine has augmented the builder with. I'm pretty sure the copyMetadata is around to make sure we don't discard the !prof. Other select combines probably drop this information. |
lib/Transforms/InstCombine/InstCombineSelect.cpp | ||
---|---|---|
966 | Correct about the !prof - although hopefully we're not dropping that anymore. In the trunc transform above, it is copied with: Builder->CreateSelect(Cond, X, TruncCVal, "narrow", &Sel) <-- last param means copy metadata from Sel. |
lib/Transforms/InstCombine/InstCombineSelect.cpp | ||
---|---|---|
966 | Ok. Nothing wrong with the style then. Sorry about that comment. And yes, the Builder->CreateSelect is copying metadata if the original select is provided. So in many situations the metadata will survive. That is kind of why I wondered why there was an explicit copy of metadata instead of using the Builder in this partiular case. (I won't learn if I don't ask questions. Thanks for you answers!) |
Why aren't you using the Builder here? Is it to avoid an implicit fold by the CreateSelect?
To me it looks like you are using a different style compared to the optimization above involving the trunc.
And I guess that if you use the Builder, then you won't need to explicitly copyMetadata? Or is that missing from the optimization involving the trunc. There was not a single explicit copyMetadata in this file until now.