Hi,

This patch folds the signed versions of min and max reduction
builtins to tree form. We can't safely fold the unsigned
versions as they do not currently have the correct type.

We must use TARGET_GIMPLE_FOLD_BUILTIN as REDUC_MIN_EXPR
is not a valid GENERIC code.

Regression tested on aarch64-none-elf with no regressions.

Thanks,
James

---
gcc/

2013-04-30  James Greenhalgh  <james.greenha...@arm.com>

        * config/aarch64/aarch64-builtins
        (aarch64_gimple_fold_builtin): Fold reduc_<su><maxmin>_ builtins.
diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c
index 3016f25..8eb32c6 100644
--- a/gcc/config/aarch64/aarch64-builtins.c
+++ b/gcc/config/aarch64/aarch64-builtins.c
@@ -1372,6 +1372,21 @@ aarch64_gimple_fold_builtin (gimple_stmt_iterator *gsi)
 						args[0],
 						NULL_TREE);
 		break;
+	      BUILTIN_VDQIF (UNOP, reduc_smax_, 10)
+		new_stmt = gimple_build_assign_with_ops (
+						REDUC_MAX_EXPR,
+						gimple_call_lhs (stmt),
+						args[0],
+						NULL_TREE);
+		break;
+	      BUILTIN_VDQIF (UNOP, reduc_smin_, 10)
+		new_stmt = gimple_build_assign_with_ops (
+						REDUC_MIN_EXPR,
+						gimple_call_lhs (stmt),
+						args[0],
+						NULL_TREE);
+		break;
+
 	    default:
 	      break;
 	    }

Reply via email to