When using only %esp in AM, which must use a SIB byte, set the index to esp, too...
authorChristoph Mallon <christoph.mallon@gmx.de>
Mon, 21 Sep 2009 13:24:29 +0000 (13:24 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Mon, 21 Sep 2009 13:24:29 +0000 (13:24 +0000)
[r26565]

ir/be/ia32/ia32_emitter.c

index 3551137..8909df2 100644 (file)
@@ -2493,9 +2493,10 @@ static void bemit_mod_am(unsigned reg, const ir_node *node)
        } else if (has_base) {
                const arch_register_t *reg = arch_get_irn_register(base);
                if (reg->index == REG_ESP) {
-                       /* for the above reason we are forced to emit a sib
-                          when base is ESP. Only the base is used */
-                       sib     = ENC_BASE(0x04);
+                       /* for the above reason we are forced to emit a sib when base is
+                        * ESP. Only the base is used, index must be ESP too, which means no
+                        * index. */
+                       sib     = ENC_BASE(0x04) | ENC_INDEX(0x04);
                        emitsib = true;
 
                /* we are forced to emit a 8bit offset as EBP base without