Re: 1024bb26337b - main - qdivrem: Predict division by zero as false.

From: Hans Petter Selasky <hselasky_at_freebsd.org>
Date: Tue, 04 Oct 2022 19:46:33 UTC
On 10/4/22 18:38, Ravi Pokala wrote:
> -----Original Message-----
> From: <owner-src-committers@freebsd.org> on behalf of Hans Petter Selasky <hselasky@FreeBSD.org>
> Date: 2022-10-04, Tuesday at 04:53
> To: <src-committers@FreeBSD.org>, <dev-commits-src-all@FreeBSD.org>, <dev-commits-src-main@FreeBSD.org>
> Subject: git: 1024bb26337b - main - qdivrem: Predict division by zero as false.
> 
>      The branch main has been updated by hselasky:
> 
>      URL: https://cgit.FreeBSD.org/src/commit/?id=1024bb26337bdc6679af477977247e9155d502bc
> 
>      commit 1024bb26337bdc6679af477977247e9155d502bc
>      Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
>      AuthorDate: 2022-10-04 10:28:25 +0000
>      Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
>      CommitDate: 2022-10-04 11:51:06 +0000
> 
>          qdivrem: Predict division by zero as false.
> 
>          Division by zero triggers an arithmetic exception and should not be very
>          common. Predict this.
> 
> Looking at this change with a little more context, I see that (static volatile const unsigned int) 'zero' is set to 0... and then used as the denominator for division. Since these are all integers, I would expect that to cause a fatal divide-by-zero exception. And yet, there's more code after that divide-by-zero.
> 
> What am I missing?
> 

Hi,

I know some rare CPU's continue executing after division by zero, but 
the ones the FreeBSD support doesn't. Maybe it's something we've 
inherited. I have no good explanation for that extra code.

--HPS