[llvm-dev] RFC: Adding 'no-overflow' keyword to 'sdiv'\'udiv'instructions

Matthias Braun via llvm-dev llvm-dev at lists.llvm.org
Mon Dec 4 11:25:47 PST 2017



> On Dec 4, 2017, at 10:46 AM, Philip Reames via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> On 12/03/2017 06:57 AM, Nuno Lopes via llvm-dev wrote:
>> Your proposal is essentially to introduce division instructions that cannot trigger UB, but return poison instead. On ISAs like x86 that means that these instructions have to be lowered with guards around them.
>> You also propose to change clang to always emit these non-UB-triggering instructions.  Is this only for vector operations or also for scalar ones? What's the performance impact of all those extra guards?
> Just to comment here, I think this really is worth measuring.  The results aren't easy to predict.  Given the optimizer may be able to frequently discharge the guard via known-bits or constant-ranges, machine-licm can move the divide to the use (thus removing the need for the guard), and the vector forms can be done as a ptest/br, the results might be nowhere as bad as it might first seem. Particularly not after some targeted tuning work.

The aarch64 (integer) division instruction returns 0 on division by 0. So this would lower nicely without extra instructions.

- Matthias

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171204/3fd1d550/attachment.html>


More information about the llvm-dev mailing list