#3065: Reorder tests in quot to improve code
--------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 6.12 branch
Component: libraries/base | Version: 6.10.1
Resolution: | Keywords:
Difficulty: Unknown | Os: Unknown/Multiple
Testcase: | Architecture: Unknown/Multiple
Failure: Runtime performance bug |
--------------------------------------+-------------------------------------
Comment (by simonmar):
Replying to [comment:6 rl]:
> I see. I guess the problem with #1042 was that x86 raises an exception
on int division overflow. IMO the right thing to do here is to use more
bits for division in the generated code. This is what gcc does, for
instance.
Are you sure gcc does this? Trying the example from #1042, it generates a
floating point exception:
{{{
$ cat 1042.c
#include <stdio.h>
main () {
int i = -2147483648;
int j = -1;
int k = i / j;
printf("%d\n", k);
}
$ gcc 1042.c --std=c99
1042.c:3: warning: return type defaults to ‘int’
$ ./a.out
[1] 18136 floating point exception (core dumped) ./a.out
}}}
I'm not sure if its possible to do a division with a 64-bit result on
32-bit x86: the `idivl` instruction takes a 64-bit divident, but gives you
a 32-bit quotient and remainder.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3065#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs