aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/aarch64/aarch64.cc12
-rw-r--r--gcc/testsuite/gcc.target/aarch64/csinc-3.c10
2 files changed, 22 insertions, 0 deletions
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index b209343..4fd8c2d 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -11607,6 +11607,18 @@ aarch64_if_then_else_costs (rtx op0, rtx op1, rtx op2, int *cost, bool speed)
/* CSINV/NEG with zero extend + const 0 (*csinv3_uxtw_insn3). */
op1 = XEXP (inner, 0);
}
+ else if (op1 == constm1_rtx || op1 == const1_rtx)
+ {
+ /* Use CSINV or CSINC. */
+ *cost += rtx_cost (op2, VOIDmode, IF_THEN_ELSE, 2, speed);
+ return true;
+ }
+ else if (op2 == constm1_rtx || op2 == const1_rtx)
+ {
+ /* Use CSINV or CSINC. */
+ *cost += rtx_cost (op1, VOIDmode, IF_THEN_ELSE, 1, speed);
+ return true;
+ }
*cost += rtx_cost (op1, VOIDmode, IF_THEN_ELSE, 1, speed);
*cost += rtx_cost (op2, VOIDmode, IF_THEN_ELSE, 2, speed);
diff --git a/gcc/testsuite/gcc.target/aarch64/csinc-3.c b/gcc/testsuite/gcc.target/aarch64/csinc-3.c
new file mode 100644
index 0000000..bde131a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/csinc-3.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-vectorize" } */
+
+int f(int *a, int n, int *b, int d)
+{
+ for(int i = 0; i < n; i++)
+ b[i] = a[i] == 100 ? 1 : d;
+ /* { dg-final { scan-assembler "csinc\tw\[0-9\].*wzr" } } */
+ return 0;
+}