efriedma added a comment. In D103958#2808966 <https://reviews.llvm.org/D103958#2808966>, @melver wrote:
> In D103958#2808861 <https://reviews.llvm.org/D103958#2808861>, @efriedma > wrote: > >> I don't like using metadata like this. Dropping metadata should generally >> preserve the semantics of the code. > > Anything better for this without introducing new instructions? Would an > argument be reasonable? If we really want to make it part of the branch, maybe add an intrinsic that can be used with callbr. Not something we've done before, but the infrastructure should be mostly there. That said, I'm not sure this is the best approach. Alternative proposal: We could add a regular intrinsic. Just ignore the control flow at the IR level, and come up with a straight-line blob that just does the right thing. I think we'd want to actually perform the load as part of the intrinsic, to avoid worrying about the consume dependency. So we'd have an intrinsic "__builtin_load_with_control_dependency()". It would lower to something along the lines of `asm("ldr %0, [%1]; cbnz %0, .+4":"=r"(dest):"r"(x):"memory");` on AArch64. The differences between the intrinsic and just using the asm I wrote: 1. We weaken the "memory" clobber to something that more accurately matches what we need. 2. We add a compiler transform to check if the branch is redundant, late in the optimization pipeline, and remove it if it is. I think this produces the code you want, and it should be easier to understand and maintain. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103958/new/ https://reviews.llvm.org/D103958 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits