[AArch64] Fold max and min reduction builtins to tree.

Submitted by James Greenhalgh on April 30, 2013, 3:21 p.m.

Details

Message ID 1367335277-23532-1-git-send-email-james.greenhalgh@arm.com
State New
Headers show

Commit Message

James Greenhalgh April 30, 2013, 3:21 p.m.
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.greenhalgh@arm.com>

	* config/aarch64/aarch64-builtins
	(aarch64_gimple_fold_builtin): Fold reduc_<su><maxmin>_ builtins.

Comments

Marcus Shawcroft April 30, 2013, 5:28 p.m.
OK
/Marcus

On 30 April 2013 16:21, James Greenhalgh <james.greenhalgh@arm.com> wrote:
>
> 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.greenhalgh@arm.com>
>
>         * config/aarch64/aarch64-builtins
>         (aarch64_gimple_fold_builtin): Fold reduc_<su><maxmin>_ builtins.

Patch hide | download patch | download mbox

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;
 	    }