Opened 11 years ago

Closed 11 years ago

Last modified 4 years ago

#921 closed bug (fixed)

Floating point with -O and -fasm is broken

Reported by: guest Owned by: igloo
Priority: normal Milestone: 6.6.1
Component: Compiler (NCG) Version: 6.4.1
Keywords: Cc: ravi@…
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


I have some simple floating-point code that fails badly when you compile it with -O and -fasm on x86_64. Here is the program:

log2 x = ceiling log_x

where log_x
Double log_x = logBase 2 (fromIntegral (max 1 x))

vals = [1, 2, 17, 259, 1000, 10000,

230 + 9000, 231 - 1, 231, 231 + 1, 232 - 1, 232, 232 + 1]

main :: IO () main = putStrLn (show (map log2 vals))

The result should be: [0,1,5,9,10,14,31,31,32,32,32,32,33]

With -O and -fasm on x86_64 the last five values are corrupted (four very large numbers I'm not going to paste here, followed by 0).

Change History (6)

comment:1 Changed 11 years ago by guest

Versions I have tried (all with the same problem) include 6.4.1, 6.4.2, 6.4.3-20061001 and 6.5-20061002.

comment:2 Changed 11 years ago by igloo

Owner: set to igloo

I have a fix for this (use q suffix instructions like cvtsi2sdq). I'm going to try to generate test cases for all the instructions, then I'll do a build and check it all looks OK.

comment:3 Changed 11 years ago by igloo

Milestone: 6.6.1

comment:4 Changed 11 years ago by ravi@…

Cool. Please let me know when a build is ready and I'll certainly be eager to try it out.

In addition, would it be possible for this fix to be included in 6.4.3 as well? It would be helpful if there were a 6.4 compiler that didn't have this issue.

comment:5 Changed 11 years ago by igloo

Resolution: fixed
Status: newclosed

Any recent nightly HEAD build should have the fix, and i've just pushed it to the 6.6 branch.

6.4.3 has been tagged now, and this fix didn't make it I'm afraid.

Thanks Ian

comment:6 Changed 4 years ago by Ian Lynagh <igloo@…>

Note: See TracTickets for help on using tickets.