View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
---|---|---|---|---|---|---|---|---|---|
0000042 | mercury | Bug | public | 2008-02-04 11:01 | 2008-10-22 15:35 | ||||
Reporter | wangp | ||||||||
Assigned To | wangp | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | resolved | Resolution | fixed | ||||||
Product Version | |||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0000042: bug with LCMC in hlc grades | ||||||||
Description | In the attached test case, a list is converted to a bag then back again. The input is [1,1,1,2,3,3,4]. The output should be the same. When the module is compiled with mmc -s hlc.gc --optimize-constructor-last-call --no-inlining the output is just "[1]". | ||||||||
Tags | No tags attached. | ||||||||
Attached Files |
|
Notes | |
wangp (developer) 2008-03-28 11:26 |
This appears to have been fixed by Mark's recent changes. |
wangp (developer) 2008-03-28 15:06 |
Sorry, I was wrong. The reason it "works" now is that the latest compiler no longer performs the LCMC optimisation on the test case at all. |
juliensf (administrator) 2008-04-04 17:43 Last edited: 2008-04-04 17:44 |
The reason that the compiler no longer performs LCMC optimisation is a change in the behaviour of common structure optimisation: Compiling with: -O2 --optimize-constructor-last-call --nolining --no-common-struct gives me the following at stage 135 (which is the last pass that does something meaningful before the LCMC pass) for the predicate to_list_2. bag_to_list.to_list_2(TypeInfo_for_T, HeadVar__1, HeadVar__2) :- ( % cannot_fail switch on `HeadVar__1' % HeadVar__1 has functor list.[]/0 HeadVar__2 = list.[] ; % HeadVar__1 has functor list.[|]/2 HeadVar__1 = list.[V_9 | Xs], V_9 = pair.(X - Int), (if V_10 = 0, int.(Int =< V_10) then bag_to_list.to_list_2(TypeInfo_for_T, Xs, HeadVar__2) else V_11 = 1, NewInt = int.(Int - V_11), V_13 = pair.(X - NewInt), V_12 = list.[V_13 | Xs], bag_to_list.to_list_2(TypeInfo_for_T, V_12, Out0), HeadVar__2 = list.[X | Out0] ) ). Enabling common structure optimisation gives the following: bag_to_list.to_list_2(TypeInfo_for_T, HeadVar__1, HeadVar__2) :- ( % cannot_fail switch on `HeadVar__1' % HeadVar__1 has functor list.[]/0 HeadVar__2 = list.[] ; % HeadVar__1 has functor list.[|]/2 HeadVar__1 = list.[V_9 | Xs], V_9 = pair.(X - Int), (if V_10 = 0, int.(Int =< V_10) then bag_to_list.to_list_2(TypeInfo_for_T, Xs, Out) else V_11 = 1, NewInt = int.(Int - V_11), V_13 = pair.(X - NewInt), V_12 = list.[V_13 | Xs], bag_to_list.to_list_2(TypeInfo_for_T, V_12, Out0), Out = list.[X | Out0] ), HeadVar__2 = Out ). The unification HeadVar__2 = Out is introduced in stage 65 by common structure optimisation and it inhibits LCMC. Compiling with --no-common-struct causes the program to exhibit the original buggy behaviour reported by Peter Wang. Since there is no advantage gained by adding the new assignment unification and given that it inhibits other optimisations this behaviour from --common-struct is also a bug. |
wangp (developer) 2008-09-03 17:10 |
Fix is here http://www.cs.mu.oz.au/research/mercury/mailing-lists/mercury-reviews/mercury-reviews.200806/0032.html but store_at_ref needs to be declared impure first. |
Issue History | |||
Date Modified | Username | Field | Change |
---|---|---|---|
2008-02-04 11:01 | wangp | New Issue | |
2008-02-04 11:01 | wangp | File Added: bag_to_list.m | |
2008-03-28 11:26 | wangp | Note Added: 0000094 | |
2008-03-28 11:27 | wangp | Status | new => resolved |
2008-03-28 11:27 | wangp | Resolution | open => fixed |
2008-03-28 11:27 | wangp | Assigned To | => wangp |
2008-03-28 15:06 | wangp | Note Added: 0000095 | |
2008-03-28 15:06 | wangp | Assigned To | wangp => |
2008-03-28 15:06 | wangp | Status | resolved => new |
2008-04-04 17:43 | juliensf | Note Added: 0000098 | |
2008-04-04 17:44 | juliensf | Note Edited: 0000098 | |
2008-09-03 17:10 | wangp | Note Added: 0000147 | |
2008-10-22 15:35 | wangp | Status | new => resolved |
2008-10-22 15:35 | wangp | Assigned To | => wangp |