Correct three bugs in bemit_incsp(): Offset 0 must emit no code, get_signed_imm_size...
authorChristoph Mallon <christoph.mallon@gmx.de>
Mon, 21 Sep 2009 13:16:31 +0000 (13:16 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Mon, 21 Sep 2009 13:16:31 +0000 (13:16 +0000)
[r26564]

ir/be/ia32/ia32_emitter.c

index 5b4ed53..3551137 100644 (file)
@@ -2845,27 +2845,32 @@ static void bemit_return(const ir_node *node)
 
 static void bemit_incsp(const ir_node *node)
 {
-       const arch_register_t *reg  = get_out_reg(node, 0);
-       int                    offs = be_get_IncSP_offset(node);
-       unsigned               size = get_signed_imm_size(offs);
-       unsigned char          w    = size == 1 ? 2 : 0;
+       int                    offs;
+       const arch_register_t *reg;
+       unsigned               size;
+       unsigned               ext;
+
+       offs = be_get_IncSP_offset(node);
+       if (offs == 0)
+               return;
 
-       bemit8(0x81 | w);
        if (offs > 0) {
+               ext = 5; /* sub */
+       } else {
+               ext = 0; /* add */
+               offs = -offs;
+       }
 
-               bemit_modru(reg, 5); /* sub */
-               if (size == 8) {
-                       bemit8(offs);
-               } else {
-                       bemit32(offs);
-               }
-       } else if (offs < 0) {
-               bemit_modru(reg, 0); /* add */
-               if (size == 8) {
-                       bemit8(-offs);
-               } else {
-                       bemit32(-offs);
-               }
+       size = get_signed_imm_size(offs);
+       bemit8(size == 1 ? 0x83 : 0x81);
+
+       reg  = get_out_reg(node, 0);
+       bemit_modru(reg, ext);
+
+       if (size == 1) {
+               bemit8(offs);
+       } else {
+               bemit32(offs);
        }
 }