On Fri, Oct 6, 2017 at 4:16 PM, Gabriele Svelto <gsve...@mozilla.com> wrote: > IIUC what you are looking for is the '+' constraint which implies the > parameter is both read and written in the asm statement, e.g.:
Thanks. On Fri, Oct 6, 2017 at 4:01 PM, Nathan Froyd <nfr...@mozilla.com> wrote: > Can you provide a slightly larger example testcase (links to > godbolt.org would be excellent) that actually uses this, so we can see > what the compiler is doing? https://godbolt.org/g/p4PQYT is the kind of thing that made me think the black_box function was wrong. Combining it with some action does seem to work in the sense that there are 16 additions instead of one addition of 16: https://godbolt.org/g/iTBXYW vs. https://godbolt.org/g/FkogJM Adding volatile changes the output even when there's no action in the loop other that the pointing going through the black box: https://godbolt.org/g/35xcCL > I think it's customary to make these sorts of asms `volatile asm` to > tell the compiler to not touch it. I don't know how to write one for > MSVC, but I think a small variant of the above should work for GCC. I omitted volatile, because the GCC manual said it has no effect on basic asm. However, it turns out it still has an effect on extended asm, which is what this is. Oops. On Fri, Oct 6, 2017 at 5:41 PM, David Major <dma...@mozilla.com> wrote: > I bet Google Benchmark will have what you want. > > As a first guess, maybe this? > https://github.com/google/benchmark/blob/master/include/benchmark/benchmark.h#L297 Thank you. I guess it's the best to import that into the tree even though it seems to only consume values without returning a value. (I've been under the impression that it would be prudent to taint benchmark inputs as untrackable by the optimizer also.) I'm a bit surprised that the MSVC code path relies on an empty out-of-line function and not on inline asm. -- Henri Sivonen hsivo...@hsivonen.fi https://hsivonen.fi/ _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform