Is this a suitable question for Stack Overflow?
It sounds like one to me - or at least, a suitable question could exist in this space. Ideally, your "few lines of C++ code" would demonstrate a general pattern of code that you find leads to this optimization failure.
I have a few lines of C++ code (Compiler Explorer) that compiles to a bit over 100 lines of filtered assembly code (no more irrelevant lines can be yanked from the output) on each of two compilers I tried.
In this circumstance, the C++ code is input and the generated assembly is output.
The generated assembly presumably assembles to machine code that can be executed without error, and which solves the problem that the original C++ code was written to perform. So there's no real sense in which it can be considered an "error message", so we aren't looking for completeness as we would in that case.
We should therefore treat the C++ according to normal standards for an MRE, and the assembly according to normal standards for program output.
Should I include just the parts of the compiler output that I find problematic (still unwieldy)?
Would an expert need to see these parts in order to understand the problem? I would guess not, in which case we should probably just see a description of what is wrong with the compiler output.
Ideally, we'd see the complete, correct expected output (I'm assuming this is considerably shorter), or at least a reasonable facsimile, along with a question about why the compiler doesn't give that result. Ideally, it would also be clear from the question, exactly why it should be reasonable to expect that the optimization could be done automatically (and that it doesn't require human intuition).
It could well turn out that the compiler is bound by some edge case that you haven't considered, such that your proposed optimization isn't actually valid unless the compiler can be given appropriate assurances (e.g., that two input memory ranges can't overlap). Assuming that you'd consider an answer that points this out to be correct, you're IMO likely on the right track with a question like this.
Should I just include the link to Compiler Explorer?
We cannot accept a question that "just" does so, regardless of your justification. If that's really the only reasonable way to avoid including hundreds of lines of "code" in your question, then that strongly counts against your question being suitable (as it suggests a question that Needs More Focus).
details
andsummary
HTML tags.std::vector
, one of which is inside a loop; other than that the code does almost no computation.