shl 64 lazarus / 62-General ---------------------------------------------------------------------- MarkMLl · 2022-03-03 18:52 Using 3.2.2 on x86_64 Linux, I find that Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i qword(1) shl 64;  results in 1. Is this intentional, and if so what's the justification? MarkMLl ---------------------------------------------------------------------- Thaddy · 2022-03-03 18:58 Hm, so it behaves like rol? I think that is a bug. 1 should go out of scope, not wrapped around. It goes for Win and Arm too. ---------------------------------------------------------------------- Kays · 2022-03-03 19:36 Quote from: MarkMLl on March 03, 2022, 07:52:07 pm[…] results in 1. Is this intentional, and if so what's the justification? […]Read the instruction manual. The second operand to the shl (and other) x86 instruction(s) is masked to the lower 6, 64-bit mode, or 5 bits. I suppose it’s an ALU-design limitation. ---------------------------------------------------------------------- MarkMLl · 2022-03-03 19:48 63's OK, 64 isn't. That complicates things when trying to combine shifts using e.g. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   result := (bitVector[3] >> by) + (bitVector[2] << (64 - by));  ...I'm not promising that's correct since I can't test it for obvious reasons. MarkMLl ---------------------------------------------------------------------- MarkMLl · 2022-03-03 19:53 Quote from: Kays on March 03, 2022, 08:36:02 pmRead the instruction manual. From the only manual that matters, which is the Language Reference Guide: Quoteshl    Bitwise shift to the left shr    Bitwise shift to the right <<    Bitwise shift to the left (same as shl) >>         Bitwise shift to the right (same as shr) MarkMLl ---------------------------------------------------------------------- AlexTP · 2022-03-03 20:25 It may be limitation of x86, so the FPC must overcome it - FPC must clear the result for n>=64. ---------------------------------------------------------------------- Thaddy · 2022-03-03 20:51 Think about range checks. But then again a shift 64 should go out of scope for 1 and not wrap. ---------------------------------------------------------------------- MarkMLl · 2022-03-03 21:21 Frankly, I can sympathise both ways. But since the shift distance is (I think) universally agreed to be zero or greater irrespective of language, then I think that Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ... << SizeOf(first_param) - second_param  is a common idiom that should result in zero in the specific case that second_param is zero. MarkMLl ---------------------------------------------------------------------- Kays · 2022-03-03 22:32 Quote from: MarkMLl on March 03, 2022, 10:21:05 pm[…]Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ... << SizeOf(first_param) - second_param is a common idiom that should result in zero in the specific case that second_param is zero.You mean bitSizeOf(ALUSInt). You are entitled to your own opinion, but this behavior won’t be changed now since there is certainly code that uses n * bitSizeOf(ALUSInt) offsets as a zero-shift idiom. Quote from: MarkMLl on March 03, 2022, 08:53:26 pmFrom the only manual that matters, which is the Language Reference Guide:Well, then MVC will add the restriction “For shift offsets smaller than zero or greater than bitSizeOf(ALUSInt) − 1 the behavior is undefined.” Great. What have we gained from that? Nothing. [I mean, it should be added, but for this discussion here it’s irrelevant.] Quote from: AlexTP on March 03, 2022, 09:25:40 pmIt may be limitation of x86, so the FPC must overcome it - FPC must clear the result for n>=64.If you want certain behavior you should write certain behavior:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i (x shl offset) * ord((offset >= 0) and (offset < bitSizeOf(ALUSint))) ---------------------------------------------------------------------- PascalDragon · 2022-03-04 09:40 Quote from: AlexTP on March 03, 2022, 09:25:40 pmIt may be limitation of x86, so the FPC must overcome it - FPC must clear the result for n>=64. That would mean a performance penalty if done for every shift operation with a variable. At most this could be done when range checks are enabled, but not in normal operation. Quote from: Kays on March 03, 2022, 11:32:37 pmQuote from: MarkMLl on March 03, 2022, 08:53:26 pmFrom the only manual that matters, which is the Language Reference Guide:Well, then MVC will add the restriction “For shift offsets smaller than zero or greater than bitSizeOf(ALUSInt) − 1 the behavior is undefined.” Great. What have we gained from that? Nothing. [I mean, it should be added, but for this discussion here it’s irrelevant.] Would someone please report a bug against the documentation? Not necessarily as "should be undefined, but more open ended so that someone like FPK or Jonas Maebe might comment as well. Quote from: MarkMLl on March 03, 2022, 10:21:05 pmBut since the shift distance is (I think) universally agreed to be zero or greater irrespective of language, then I think that Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ... << SizeOf(first_param) - second_param  is a common idiom that should result in zero in the specific case that second_param is zero. Not so common that GCC doesn't return 1 for your original example as well (and with a constant it even warns that it's out of range; maybe FPC should as well). In the end the result depends upon the used processor. ---------------------------------------------------------------------- MarkMLl · 2022-03-04 10:02 Quote from: PascalDragon on March 04, 2022, 10:40:13 amNot so common that GCC doesn't return 1 for your original example as well (and with a constant it even warns that it's out of range; maybe FPC should as well). In the end the result depends upon the used processor. As I said: on reflection I can see both sides of this, and a mask on the shift count is almost certainly something I'd have done wearing my hardware hat. This is more a documentation issue for Mantis than anything else. MarkMLl ---------------------------------------------------------------------- AlexTP · 2022-03-04 10:13 Like "safe FDIV", maybe add the FPC option "safe shifts"? ---------------------------------------------------------------------- MarkMLl · 2022-03-04 10:40 Maybe, but I think the best parallel is the ISO-mode mod operation. MarkMLl ---------------------------------------------------------------------- Kays · 2022-03-04 20:23 Quote from: MarkMLl on March 04, 2022, 11:02:36 am[…] This is more a documentation issue for Mantis than anything else.I’m sure this is out of habit, but we’re using GitLab now. The issue has been reported. ---------------------------------------------------------------------- MarkMLl · 2022-03-04 20:49 Quote from: Kays on March 04, 2022, 09:23:26 pmQuote from: MarkMLl on March 04, 2022, 11:02:36 am[…] This is more a documentation issue for Mantis than anything else.I’m sure this is out of habit, but we’re using GitLab now. The issue has been reported. Thanks, I hoped my hint wasn't excessively subtle :-) Sorry, but as previously discussed, and without intending disrespect to the community, I'm not putting any time into Git and I'll interact with the new bug reporting system only when it becomes unavoidable. MarkMLl ---------------------------------------------------------------------- Kays · 2022-03-04 22:02 Quote from: MarkMLl on March 04, 2022, 09:49:44 pm[…] I'm not putting any time into Git and I'll interact with the new bug reporting system only when it becomes unavoidable.I’m confused. In your forum signature there’s a link to your GitHub repositories, right? So you are using git(1). No? ---------------------------------------------------------------------- MarkMLl · 2022-03-05 09:12 Quote from: Kays on March 04, 2022, 11:02:52 pmI’m confused. In your forum signature there’s a link to your GitHub repositories, right? So you are using git(1). No? No. Uploading snapshots as and when I feel I might have something interested. I emphatically do not want to get into a flame war over this but I reiterate my position: Git is fine for development teams, but not fine for rolling trunk distribution where the Subversion-style revision is more appropriate. MarkMLl