return dmax[0] + dmax[1] + dmax[2];
}
-/* { dg-final { scan-tree-dump "appears to be optimized to a join point for if-convertable half-diamond" "split-paths" } } */
+/* Split-paths shouldn't do anything here, if there's a diamond it would
+ be if-convertible. */
+/* { dg-final { scan-tree-dump-not "Duplicating join block" "split-paths" } } */
/* { dg-do compile } */
/* { dg-options " -O2 -msse4.1 -mfpmath=sse" } */
-/* { dg-final { scan-assembler-times {(?n)mins[sd]} 2 { target { ! ia32 } } } } */
-/* { dg-final { scan-assembler-times {(?n)maxs[sd]} 2 { target { ! ia32 } } } } */
-/* Ideally cond_swap_df is also optimized to minsd/maxsd. */
-/* { dg-final { scan-assembler-times {(?n)mins[sd]} 1 { target ia32 } } } */
-/* { dg-final { scan-assembler-times {(?n)maxs[sd]} 1 { target ia32 } } } */
+/* { dg-final { scan-assembler-times {(?n)mins[sd]} 2 } } */
+/* { dg-final { scan-assembler-times {(?n)maxs[sd]} 2 } } */
void __cond_swap_df(double* __x, double* __y) {
_Bool __r = (*__x < *__y);
/* { dg-do compile } */
/* { dg-options "-O2 -mavx512fp16" } */
-/* { dg-final { scan-assembler-times "vmaxsh\[ \\t\]" 1 } } */
+/* { dg-final { scan-assembler-times "vm\[ai\]\[nx\]sh\[ \\t\]" 1 } } */
/* { dg-final { scan-assembler-not "vcomish\[ \\t\]" } } */
/* { dg-final { scan-assembler-not "vmovsh\[ \\t\]" { target { ! ia32 } } } } */
/* { dg-do compile } */
/* { dg-options "-O2 -mavx512fp16" } */
-/* { dg-final { scan-assembler-times "vmaxsh\[ \\t\]" 1 } } */
+/* { dg-final { scan-assembler-times "vm\[ai\]\[nx\]sh\[ \\t\]" 1 } } */
/* { dg-final { scan-assembler-not "vcomish\[ \\t\]" } } */
/* { dg-final { scan-assembler-not "vmovsh\[ \\t\]" { target { ! ia32 } } } } */
/* { dg-do compile } */
/* { dg-options "-O2 -msse2 -mfpmath=sse" } */
/* { dg-final { scan-assembler-times "minss" 1 } } */
-/* { dg-final { scan-assembler-not "movaps" } } */
-/* { dg-final { scan-assembler-not "movss" } } */
+/* { dg-final { scan-assembler-not "movaps" { xfail *-*-* } } } */
+/* { dg-final { scan-assembler-not "movss" { xfail *-*-* } } } */
typedef float vec __attribute__((vector_size(16)));
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -msse2" } */
+
+void test(double* __restrict d1, double* __restrict d2, double* __restrict d3)
+{
+ for (int n = 0; n < 2; ++n)
+ d3[n] = d1[n] < d2[n] ? d1[n] : d2[n];
+}
+
+/* { dg-final { scan-assembler "minpd" } } */
tree type = TREE_TYPE (PHI_RESULT (phi));
- /* The optimization may be unsafe due to NaNs. */
- if (HONOR_NANS (type) || HONOR_SIGNED_ZEROS (type))
- return false;
-
gcond *cond = as_a <gcond *> (*gsi_last_bb (cond_bb));
enum tree_code cmp = gimple_cond_code (cond);
tree rhs = gimple_cond_rhs (cond);
else
return false;
}
+ else if (HONOR_NANS (type) || HONOR_SIGNED_ZEROS (type))
+ /* The optimization may be unsafe due to NaNs. */
+ return false;
else if (middle_bb != alt_middle_bb && threeway_p)
{
/* Recognize the following case:
/* Emit the statement to compute min/max. */
gimple_seq stmts = NULL;
tree phi_result = PHI_RESULT (phi);
- result = gimple_build (&stmts, minmax, TREE_TYPE (phi_result), arg0, arg1);
+
+ /* When we can't use a MIN/MAX_EXPR still make sure the expression
+ stays in a form to be recognized by ISA that map to IEEE x > y ? x : y
+ semantics (that's not IEEE max semantics). */
+ if (HONOR_NANS (type) || HONOR_SIGNED_ZEROS (type))
+ {
+ result = gimple_build (&stmts, cmp, boolean_type_node,
+ gimple_cond_lhs (cond), rhs);
+ result = gimple_build (&stmts, COND_EXPR, TREE_TYPE (phi_result),
+ result, arg_true, arg_false);
+ }
+ else
+ result = gimple_build (&stmts, minmax, TREE_TYPE (phi_result), arg0, arg1);
gsi = gsi_last_bb (cond_bb);
gsi_insert_seq_before (&gsi, stmts, GSI_NEW_STMT);