OSDN Git Service

tcg/optimize: Use fold_xx_to_i for rem
authorRichard Henderson <richard.henderson@linaro.org>
Mon, 25 Oct 2021 18:30:33 +0000 (11:30 -0700)
committerRichard Henderson <richard.henderson@linaro.org>
Fri, 29 Oct 2021 03:55:07 +0000 (20:55 -0700)
Recognize the constant function for remainder.

Suggested-by: Luis Pires <luis.pires@eldorado.org.br>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
tcg/optimize.c

index f8b0709..7ac63c9 100644 (file)
@@ -1624,7 +1624,11 @@ static bool fold_qemu_st(OptContext *ctx, TCGOp *op)
 
 static bool fold_remainder(OptContext *ctx, TCGOp *op)
 {
-    return fold_const2(ctx, op);
+    if (fold_const2(ctx, op) ||
+        fold_xx_to_i(ctx, op, 0)) {
+        return true;
+    }
+    return false;
 }
 
 static bool fold_setcond(OptContext *ctx, TCGOp *op)