瀏覽代碼

* if both labels of a case label are equal, we still cannot skip the comparison in a jump tree, resolves #31589

git-svn-id: trunk@35880 -
florian 8 年之前
父節點
當前提交
50dba9ad66
共有 5 個文件被更改,包括 232 次插入48 次删除
  1. 1 0
      .gitattributes
  2. 16 19
      compiler/arm/narmset.pas
  3. 8 10
      compiler/ncgset.pas
  4. 16 19
      compiler/x86/nx86set.pas
  5. 191 0
      tests/webtbs/tw31589.pp

+ 1 - 0
.gitattributes

@@ -15449,6 +15449,7 @@ tests/webtbs/tw31431.pp svneol=native#text/pascal
 tests/webtbs/tw3144.pp svneol=native#text/plain
 tests/webtbs/tw31521.pp svneol=native#text/pascal
 tests/webtbs/tw3157.pp svneol=native#text/plain
+tests/webtbs/tw31589.pp svneol=native#text/pascal
 tests/webtbs/tw31596.pp svneol=native#text/pascal
 tests/webtbs/tw3160a.pp svneol=native#text/plain
 tests/webtbs/tw3160b.pp svneol=native#text/plain

+ 16 - 19
compiler/arm/narmset.pas

@@ -424,25 +424,22 @@ implementation
           { no range label: }
           if p^._low=p^._high then
             begin
-               if greaterlabel=lesslabel then
-                 begin
-                   if p^._low-1<>parentvalue then
-                     hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,OC_NE,p^._low,hregister,lesslabel);
-                 end
-               else
-                 begin
-                   cmplow:=p^._low-1<>parentvalue;
-                   if cmplow then
-                     hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_lt,p^._low,hregister,lesslabel);
-                   if p^._high+1<>parentvalue then
-                     begin
-                       if cmplow then
-                         hlcg.a_jmp_flags(current_asmdata.CurrAsmList,cond_gt,greaterlabel)
-                       else
-                         hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_gt,p^._low,hregister,greaterlabel);
-                     end;
-                 end;
-               hlcg.a_jmp_always(current_asmdata.CurrAsmList,blocklabel(p^.blockid));
+              if greaterlabel=lesslabel then
+                hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,OC_NE,p^._low,hregister,lesslabel)
+              else
+                begin
+                  cmplow:=p^._low-1<>parentvalue;
+                  if cmplow then
+                    hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_lt,p^._low,hregister,lesslabel);
+                  if p^._high+1<>parentvalue then
+                    begin
+                      if cmplow then
+                        hlcg.a_jmp_flags(current_asmdata.CurrAsmList,cond_gt,greaterlabel)
+                      else
+                        hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_gt,p^._low,hregister,greaterlabel);
+                    end;
+                end;
+              hlcg.a_jmp_always(current_asmdata.CurrAsmList,blocklabel(p^.blockid));
             end
           else
             begin

+ 8 - 10
compiler/ncgset.pas

@@ -923,16 +923,14 @@ implementation
           { no range label: }
           if p^._low=p^._high then
             begin
-               if greaterlabel=lesslabel then
-                 begin
-                   hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, OC_NE,p^._low,hregister, lesslabel);
-                 end
-               else
-                 begin
-                   hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize, jmp_lt,p^._low,hregister, lesslabel);
-                   hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize, jmp_gt,p^._low,hregister, greaterlabel);
-                 end;
-               hlcg.a_jmp_always(current_asmdata.CurrAsmList,blocklabel(p^.blockid));
+              if greaterlabel=lesslabel then
+                hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, OC_NE,p^._low,hregister, lesslabel)
+              else
+                begin
+                  hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize, jmp_lt,p^._low,hregister, lesslabel);
+                  hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize, jmp_gt,p^._low,hregister, greaterlabel);
+                end;
+              hlcg.a_jmp_always(current_asmdata.CurrAsmList,blocklabel(p^.blockid));
             end
           else
             begin

+ 16 - 19
compiler/x86/nx86set.pas

@@ -285,25 +285,22 @@ implementation
           { no range label: }
           if p^._low=p^._high then
             begin
-               if greaterlabel=lesslabel then
-                 begin
-                   if p^._low-1<>parentvalue then
-                     hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,OC_NE,p^._low,hregister,lesslabel);
-                 end
-               else
-                 begin
-                   cmplow:=p^._low-1<>parentvalue;
-                   if cmplow then
-                     hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_lt,p^._low,hregister,lesslabel);
-                   if p^._high+1<>parentvalue then
-                     begin
-                       if cmplow then
-                         hlcg.a_jmp_flags(current_asmdata.CurrAsmList,cond_gt,greaterlabel)
-                       else
-                         hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_gt,p^._low,hregister,greaterlabel);
-                     end;
-                 end;
-               hlcg.a_jmp_always(current_asmdata.CurrAsmList,blocklabel(p^.blockid));
+              if greaterlabel=lesslabel then
+                hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,OC_NE,p^._low,hregister,lesslabel)
+              else
+                begin
+                  cmplow:=p^._low-1<>parentvalue;
+                  if cmplow then
+                    hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_lt,p^._low,hregister,lesslabel);
+                  if p^._high+1<>parentvalue then
+                    begin
+                      if cmplow then
+                        hlcg.a_jmp_flags(current_asmdata.CurrAsmList,cond_gt,greaterlabel)
+                      else
+                        hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_gt,p^._low,hregister,greaterlabel);
+                    end;
+                end;
+              hlcg.a_jmp_always(current_asmdata.CurrAsmList,blocklabel(p^.blockid));
             end
           else
             begin

+ 191 - 0
tests/webtbs/tw31589.pp

@@ -0,0 +1,191 @@
+{ %opt=-O1 }
+
+program testcase;
+
+{$MODE DELPHI}
+
+const
+  CM_ACTIVATE = $B000;
+  WM_LCL_SOCK_ASYNC = 1024 + $500;
+  WM_QUERYOPEN = 19;
+  WM_NULL = 0;
+  WM_ENTERIDLE = 289;
+  WM_ACTIVATE = 6;
+  WM_DPICHANGED = 736;
+  WM_IME_ENDCOMPOSITION = 270;
+  WM_CANCELMODE = 31;
+  WM_CAPTURECHANGED = 533;
+  WM_CHAR = 258;
+  WM_MENUCHAR = 288;
+  WM_CLOSE = 16;
+  WM_INITMENUPOPUP = 279;
+  WM_MENUSELECT = 287;
+  WM_COMMAND = 273;
+  WM_CTLCOLORMSGBOX = 306;
+  WM_CTLCOLORSTATIC = 312;
+  WM_CLEAR = 771;
+  WM_COPY = 769;
+  WM_CUT = 768;
+  WM_DESTROY = 2;
+  WM_DESTROYCLIPBOARD = 775;
+  WM_DRAWITEM = 43;
+  WM_ENABLE = 10;
+  WM_ERASEBKGND = 20;
+  WM_EXITMENULOOP = 530;
+  WM_GETDLGCODE = 135;
+  WM_HELP = 83;
+  WM_HOTKEY = 786;
+  WM_HSCROLL = 276;
+  WM_VSCROLL = 277;
+  WM_KEYDOWN = 256;
+  WM_KEYUP = 257;
+  WM_KILLFOCUS = 8;
+  WM_LBUTTONDBLCLK = 515;
+  WM_LBUTTONDOWN = 513;
+  WM_LBUTTONUP = 514;
+  WM_RBUTTONDBLCLK = 518;
+  WM_RBUTTONDOWN = 516;
+  WM_RBUTTONUP = 517;
+  WM_MBUTTONDBLCLK = 521;
+  WM_MBUTTONDOWN = 519;
+  WM_MBUTTONUP = 520;
+  WM_XBUTTONDBLCLK = 525;
+  WM_XBUTTONDOWN = 523;
+  WM_XBUTTONUP = 524;
+  WM_MOUSEHOVER = 673;
+  WM_MOUSELEAVE = 675;
+  WM_MOUSEMOVE = 512;
+  WM_MOUSEWHEEL = 522;
+  WM_DROPFILES = 563;
+  WM_NCHITTEST = 132;
+  WM_NCLBUTTONDOWN = 161;
+  WM_NCMOUSEMOVE = 160;
+  WM_NCMOUSEHOVER = 672;
+  WM_NOTIFY = 78;
+  WM_PAINT = 15;
+  WM_PRINTCLIENT = 792;
+  WM_PASTE = 770;
+  WM_CONTEXTMENU = 123;
+  WM_SETCURSOR = 32;
+  WM_SETFOCUS = 7;
+  WM_SHOWWINDOW = 24;
+  WM_SYSCHAR = 262;
+  WM_SYSCOMMAND = 274;
+  WM_SYSKEYDOWN = 260;
+  WM_SYSKEYUP = 261;
+  WM_TIMER = 275;
+  WM_WINDOWPOSCHANGING = 70;
+  WM_WINDOWPOSCHANGED = 71;
+  WM_MEASUREITEM = 44;
+  WM_SETTINGCHANGE = 26;
+  WM_THEMECHANGED = 794;
+  WM_UPDATEUISTATE = 296;
+  WM_IME_COMPOSITION = 271;
+  WM_IME_COMPOSITIONFULL = 644;
+  WM_IME_CONTROL = 643;
+  WM_IME_NOTIFY = 642;
+  WM_IME_REQUEST = 648;
+  WM_IME_SELECT = 645;
+  WM_IME_SETCONTEXT = 641;
+  WM_IME_STARTCOMPOSITION = 269;
+  WM_ACTIVATEAPP = 28;
+  WM_DISPLAYCHANGE = 126;
+
+procedure DoError(c : Cardinal);
+  begin
+    writeln('Case ',c);
+    halt(c);
+  end;
+
+
+var
+  Msg: Cardinal;
+begin
+  Msg := WM_QUERYOPEN;
+  case Msg of
+    WM_NULL: DoError(1);
+    WM_ENTERIDLE: DoError(2);
+    WM_ACTIVATE: DoError(3);
+    WM_DPICHANGED: DoError(4);
+    WM_IME_ENDCOMPOSITION: DoError(5);
+    WM_CANCELMODE: DoError(6);
+    WM_CAPTURECHANGED: DoError(7);
+    WM_CHAR: DoError(8);
+    WM_MENUCHAR: DoError(9);
+    WM_CLOSE: DoError(10);
+    WM_INITMENUPOPUP: DoError(11);
+    WM_MENUSELECT: DoError(12);
+    WM_COMMAND: DoError(13);
+    WM_CTLCOLORMSGBOX..WM_CTLCOLORSTATIC: DoError(14);
+    WM_CLEAR: DoError(15);
+    WM_COPY: DoError(16);
+    WM_CUT: DoError(17);
+    WM_DESTROY: DoError(18);
+    WM_DESTROYCLIPBOARD: DoError(19);
+    WM_DRAWITEM: DoError(20);
+    WM_ENABLE: DoError(21);
+    WM_ERASEBKGND: DoError(22);
+    WM_EXITMENULOOP: DoError(23);
+    WM_GETDLGCODE: DoError(24);
+    WM_HELP: DoError(25);
+    WM_HOTKEY: DoError(26);
+    WM_HSCROLL,
+    WM_VSCROLL: DoError(27);
+    WM_KEYDOWN: DoError(28);
+    WM_KEYUP: DoError(29);
+    WM_KILLFOCUS: DoError(30);
+    WM_LBUTTONDBLCLK: DoError(31);
+    WM_LBUTTONDOWN: DoError(32);
+    WM_LBUTTONUP: DoError(33);
+    WM_RBUTTONDBLCLK: DoError(34);
+    WM_RBUTTONDOWN: DoError(35);
+    WM_RBUTTONUP: DoError(36);
+    WM_MBUTTONDBLCLK: DoError(37);
+    WM_MBUTTONDOWN: DoError(38);
+    WM_MBUTTONUP: DoError(39);
+    WM_XBUTTONDBLCLK: DoError(40);
+    WM_XBUTTONDOWN: DoError(41);
+    WM_XBUTTONUP: DoError(42);
+    WM_MOUSEHOVER: DoError(43);
+    WM_MOUSELEAVE: DoError(44);
+    WM_MOUSEMOVE: DoError(45);
+    WM_MOUSEWHEEL: DoError(46);
+    WM_DROPFILES: DoError(47);
+    WM_NCHITTEST: DoError(48);
+    WM_NCLBUTTONDOWN: DoError(49);
+    WM_NCMOUSEMOVE,
+    WM_NCMOUSEHOVER: DoError(50);
+    WM_NOTIFY: DoError(51);
+    WM_PAINT: DoError(52);
+    WM_PRINTCLIENT: DoError(53);
+    WM_PASTE: DoError(54);
+    WM_CONTEXTMENU: DoError(55);
+    WM_SETCURSOR: DoError(56);
+    CM_ACTIVATE: DoError(57);
+    WM_SETFOCUS: DoError(58);
+    WM_SHOWWINDOW: DoError(59);
+    WM_SYSCHAR: DoError(60);
+    WM_SYSCOMMAND: DoError(61);
+    WM_SYSKEYDOWN: DoError(62);
+    WM_SYSKEYUP: DoError(63);
+    WM_TIMER: DoError(64);
+    WM_WINDOWPOSCHANGING: DoError(65);
+    WM_WINDOWPOSCHANGED: DoError(66);
+    WM_MEASUREITEM: DoError(67);
+    WM_SETTINGCHANGE: DoError(68);
+    WM_THEMECHANGED: DoError(69);
+    WM_UPDATEUISTATE: DoError(70);
+    WM_LCL_SOCK_ASYNC: DoError(71);
+    WM_IME_COMPOSITION,
+    WM_IME_COMPOSITIONFULL,
+    WM_IME_CONTROL,
+    WM_IME_NOTIFY,
+    WM_IME_REQUEST,
+    WM_IME_SELECT,
+    WM_IME_SETCONTEXT,
+    WM_IME_STARTCOMPOSITION: DoError(72);
+    WM_ACTIVATEAPP: DoError(73);
+    WM_DISPLAYCHANGE: DoError(74);
+  end;
+  writeln('Ok');
+end.