Open Quuxplusone opened 3 years ago
(In reply to Daan Sprenkels from comment #0)
> This assembly snippet has a store that could be eliminated.
To be clear: The store operation is only needed when %cond is 1. When %cond is
0, it can be moved to one line earlier, before the .LBB0_2 label.
Note that the branches are re-intoruced in the backend by https://github.com/llvm/llvm-project/blob/master/llvm/lib/Target/X86/X86CmovConversion.cpp which determines this to be more profitable than the conditional move.
At this point, DSE is not run again and I do not think we have a version for the backend.
For AArch64, csel is generated (https://godbolt.org/z/sbGEKo), which is probably preferred in practice over an additional conditional branch.
The following IR:
is compiled to the following X86:
This assembly snippet has a store that could be eliminated.
Godbolt: https://godbolt.org/z/Yz64eh