diff options
Diffstat (limited to 'src/lj_asm.c')
-rw-r--r-- | src/lj_asm.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c index d395010d..85962ab1 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c | |||
@@ -3005,6 +3005,17 @@ static void asm_neg_not(ASMState *as, IRIns *ir, x86Group3 xg) | |||
3005 | ra_left(as, dest, ir->op1); | 3005 | ra_left(as, dest, ir->op1); |
3006 | } | 3006 | } |
3007 | 3007 | ||
3008 | static void asm_min_max(ASMState *as, IRIns *ir, int cc) | ||
3009 | { | ||
3010 | Reg right, dest = ra_dest(as, ir, RSET_GPR); | ||
3011 | IRRef lref = ir->op1, rref = ir->op2; | ||
3012 | if (irref_isk(rref)) { lref = rref; rref = ir->op1; } | ||
3013 | right = ra_alloc1(as, rref, rset_exclude(RSET_GPR, dest)); | ||
3014 | emit_rr(as, XO_CMOV + (cc<<24), REX_64IR(ir, dest), right); | ||
3015 | emit_rr(as, XO_CMP, REX_64IR(ir, dest), right); | ||
3016 | ra_left(as, dest, lref); | ||
3017 | } | ||
3018 | |||
3008 | static void asm_bitswap(ASMState *as, IRIns *ir) | 3019 | static void asm_bitswap(ASMState *as, IRIns *ir) |
3009 | { | 3020 | { |
3010 | Reg dest = ra_dest(as, ir, RSET_GPR); | 3021 | Reg dest = ra_dest(as, ir, RSET_GPR); |
@@ -4067,8 +4078,18 @@ static void asm_ir(ASMState *as, IRIns *ir) | |||
4067 | break; | 4078 | break; |
4068 | case IR_ABS: asm_fparith(as, ir, XO_ANDPS); break; | 4079 | case IR_ABS: asm_fparith(as, ir, XO_ANDPS); break; |
4069 | 4080 | ||
4070 | case IR_MIN: asm_fparith(as, ir, XO_MINSD); break; | 4081 | case IR_MIN: |
4071 | case IR_MAX: asm_fparith(as, ir, XO_MAXSD); break; | 4082 | if (irt_isnum(ir->t)) |
4083 | asm_fparith(as, ir, XO_MINSD); | ||
4084 | else | ||
4085 | asm_min_max(as, ir, CC_G); | ||
4086 | break; | ||
4087 | case IR_MAX: | ||
4088 | if (irt_isnum(ir->t)) | ||
4089 | asm_fparith(as, ir, XO_MAXSD); | ||
4090 | else | ||
4091 | asm_min_max(as, ir, CC_L); | ||
4092 | break; | ||
4072 | 4093 | ||
4073 | case IR_FPMATH: case IR_ATAN2: case IR_LDEXP: | 4094 | case IR_FPMATH: case IR_ATAN2: case IR_LDEXP: |
4074 | asm_fpmath(as, ir); | 4095 | asm_fpmath(as, ir); |