[PATCH] D135451: [TTI] New PPC target hook enableUncondDivisionSpeculation

Alex Gatea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 09:49:22 PDT 2022


alexgatea added a comment.

In D135451#3843081 <https://reviews.llvm.org/D135451#3843081>, @fhahn wrote:

> In D135451#3843064 <https://reviews.llvm.org/D135451#3843064>, @alexgatea wrote:
>
>> In D135451#3842992 <https://reviews.llvm.org/D135451#3842992>, @fhahn wrote:
>>
>>> IIUC this proposal would effectively re-define `udiv` and `urem`'s semantics on the IR level to not have undefined behavior for PPC?
>>
>> I don't think that's quite correct. We still view them as undefined, it's just that we allow further optimizations to happen that we previously bailed out of. The example I gave shows exactly this; without the speculative execution the div is still hoisted to the preheader, but this is done much later in the pipeline by MachineLICM so we do not optimize it fully (because IndVarSimplifyPass occurs earlier).
>
> Right, but the reason `MachineLICM` can do this today is because at this point we are dealing with machine instructions.
>
> In terms of LLVM IR semantics, this change would allow hoisting an instruction that may produce UB into a path that didn't have UB before AFAICT.

I see what you mean. It's definitely a valid point, let's see what others think as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135451/new/

https://reviews.llvm.org/D135451



More information about the llvm-commits mailing list