Merge pull request #3436 from ntherning/fix-alt-dir-separator-not-replaced-in-Path...
[mono.git] / mono / mini / local-propagation.c
index fc6eca575d6e611d2a752b767e9a2836cb1d8375..04373359fb46ead9bc1ea8d96249d33ee4c15948 100644 (file)
@@ -219,8 +219,14 @@ mono_strength_reduction_division (MonoCompile *cfg, MonoInst *ins)
                        struct magic_signed mag;
                        int power2 = mono_is_power_of_two (ins->inst_imm);
                        /* The decomposition doesn't handle exception throwing */
-                       if (ins->inst_imm == 0 || ins->inst_imm == -1)
+                       /* Optimization with MUL does not apply for -1, 0 and 1 divisors */
+                       if (ins->inst_imm == 0 || ins->inst_imm == -1) {
                                break;
+                       } else if (ins->inst_imm == 1) {
+                               ins->opcode = OP_MOVE;
+                               ins->inst_imm = 0;
+                               break;
+                       }
                        allocated_vregs = TRUE;
                        if (power2 == 1) {
                                guint32 r1 = alloc_ireg (cfg);
@@ -356,7 +362,8 @@ mono_strength_reduction_ins (MonoCompile *cfg, MonoInst *ins, const char **spec)
        }
        case OP_IDIV_UN_IMM:
        case OP_IDIV_IMM: {
-               allocated_vregs = mono_strength_reduction_division (cfg, ins);
+               if (!COMPILE_LLVM (cfg))
+                       allocated_vregs = mono_strength_reduction_division (cfg, ins);
                break;
        }
 #if SIZEOF_REGISTER == 8