OSDN Git Service

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

Suggested-by: Luis Pires <luis.pires@eldorado.org.br>
Reviewed-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 907049f..f8b0709 100644 (file)
@@ -1218,7 +1218,11 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op)
 
 static bool fold_divide(OptContext *ctx, TCGOp *op)
 {
-    return fold_const2(ctx, op);
+    if (fold_const2(ctx, op) ||
+        fold_xi_to_x(ctx, op, 1)) {
+        return true;
+    }
+    return false;
 }
 
 static bool fold_dup(OptContext *ctx, TCGOp *op)