|
@@ -766,6 +766,7 @@ static int do_constant_folding_cond1(OptContext *ctx, TCGOp *op, TCGArg dest,
|
|
TCGArg *p1, TCGArg *p2, TCGArg *pcond)
|
|
TCGArg *p1, TCGArg *p2, TCGArg *pcond)
|
|
{
|
|
{
|
|
TCGCond cond;
|
|
TCGCond cond;
|
|
|
|
+ TempOptInfo *i1;
|
|
bool swap;
|
|
bool swap;
|
|
int r;
|
|
int r;
|
|
|
|
|
|
@@ -783,19 +784,21 @@ static int do_constant_folding_cond1(OptContext *ctx, TCGOp *op, TCGArg dest,
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ i1 = arg_info(*p1);
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* TSTNE x,x -> NE x,0
|
|
* TSTNE x,x -> NE x,0
|
|
- * TSTNE x,-1 -> NE x,0
|
|
|
|
|
|
+ * TSTNE x,i -> NE x,0 if i includes all nonzero bits of x
|
|
*/
|
|
*/
|
|
- if (args_are_copies(*p1, *p2) || arg_is_const_val(*p2, -1)) {
|
|
|
|
|
|
+ if (args_are_copies(*p1, *p2) ||
|
|
|
|
+ (arg_is_const(*p2) && (i1->z_mask & ~arg_info(*p2)->val) == 0)) {
|
|
*p2 = arg_new_constant(ctx, 0);
|
|
*p2 = arg_new_constant(ctx, 0);
|
|
*pcond = tcg_tst_eqne_cond(cond);
|
|
*pcond = tcg_tst_eqne_cond(cond);
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
- /* TSTNE x,sign -> LT x,0 */
|
|
|
|
- if (arg_is_const_val(*p2, (ctx->type == TCG_TYPE_I32
|
|
|
|
- ? INT32_MIN : INT64_MIN))) {
|
|
|
|
|
|
+ /* TSTNE x,i -> LT x,0 if i only includes sign bit copies */
|
|
|
|
+ if (arg_is_const(*p2) && (arg_info(*p2)->val & ~i1->s_mask) == 0) {
|
|
*p2 = arg_new_constant(ctx, 0);
|
|
*p2 = arg_new_constant(ctx, 0);
|
|
*pcond = tcg_tst_ltge_cond(cond);
|
|
*pcond = tcg_tst_ltge_cond(cond);
|
|
return -1;
|
|
return -1;
|