[PATCH] D135451: [TTI] New PPC target hook enableUncondDivisionSpeculation
Alex Gatea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 20 10:26:09 PDT 2022
alexgatea added a comment.
In D135451#3871711 <https://reviews.llvm.org/D135451#3871711>, @arsenm wrote:
> In D135451#3859075 <https://reviews.llvm.org/D135451#3859075>, @alexgatea wrote:
>
>> In D135451#3849697 <https://reviews.llvm.org/D135451#3849697>, @arsenm wrote:
>>
>>> Could you instead insert a clamp of the divisor and then pattern match that out during selection?
>>
>> Hmm not sure what you mean by selection. Could you please elaborate (perhaps with an example)?
>
> If you speculate sdiv x, y, replace it with sdiv x, (y == 0 ? 1 : y) or whatever behavior you get for this case. In your backend, then pattern match the divide by 0 check when selecting to the instruction
I see what you mean. But what if the optimizer in the meantime changes/removes the select instruction? E.g. if y = foo() where foo() always returns 0 then the optimizer will at some point replace (y == 0 ? 1 : y) with 1. Also, how can we know in the backend that the original instruction was sdiv x, y and not actually sdiv x, (y == 0 ? 1 : y) ?
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