-
Implement propagation of stores to loads in single basic blocks · 3ffbd62bNicolas Capens authored
For loads following stores in the same basic block, replace their result with the data that was stored. It transforms the output of the StoresInMultipleBlocks test from: sub rsp,38h mov dword ptr [rsp],0Dh cmp ecx,0 je a mov dword ptr [rsp],4 add dword ptr [rsp],3 b: mov eax,dword ptr [rsp] add rsp,38h ret a: mov dword ptr [rsp],6 add dword ptr [rsp],5 jmp b Into: sub rsp,38h mov dword ptr [rsp],0Dh cmp ecx,0 je a mov dword ptr [rsp],4 mov eax,4 add eax,3 mov dword ptr [rsp],eax b: mov eax,dword ptr [rsp] add rsp,38h ret a: mov dword ptr [rsp],6 mov eax,6 add eax,5 mov dword ptr [rsp],eax jmp b While at first this might seem like a regression, note that `add [rsp],3` performs both a load and a store. The optimization pass eliminated two load operations from this test. The redundant stores will be eliminated by a subsequent change. Also adds a unit test for the case where store-to-load propagation should not be performed due to an indirect store through a pointer happening in between. Bug: b/179668593 Change-Id: I6ca133ac4e77bbbc3efd517dff6e8dee6d2dc147 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52533 Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by:
Nicolas Capens <nicolascapens@google.com> Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Reviewed-by:
Antonio Maiorano <amaiorano@google.com>
3ffbd62b
×