[PATCH] D37289: [X86] Speculatively load operands of select instruction

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 31 06:26:30 PDT 2017


spatel added a comment.

In https://reviews.llvm.org/D37289#857435, @lsaba wrote:

> In https://reviews.llvm.org/D37289#857007, @spatel wrote:
>
> > I didn't look at the implementation, but why is it safe to speculate loads in these tests? I can create an example where one of the pointers in the select is unmapped, so speculating that load will crash in the general case.
>
>
> The implementation handles a specific case where both operands of the select are GEPs into elements of the same struct, correct me if i'm wrong but this should be safe


I don't see how being elements of one struct changes anything. Just because one pointer is dereferenceable does not make the other dereferenceable? You would need 'dereferenceable' metadata or some other means to know that either load is safe to hoist ahead of the select.

You're proposing this transform as an x86-specific pass, so maybe I'm missing something. Is there some feature of x86 that makes speculating the load safe? I'm guessing no because I tested the example I was thinking of on x86, and this transform crashes there.


Repository:
  rL LLVM

https://reviews.llvm.org/D37289





More information about the llvm-commits mailing list