--- /dev/null
+ /* { dg-do compile } */
+ /* { dg-options "-O2 -ftree-vectorize -fdump-tree-ifcvt-stats" } */
+
+void
+test (int *dst, float *arr, int *pred, int n)
+{
+ for (int i = 0; i < n; i++)
+ {
+ int pred_i = pred[i];
+ float arr_i = arr[i];
+
+ dst[i] = pred_i ? (int)arr_i : 5;
+ }
+}
+
+/* We expect this to fail if_convertible_loop_p so long as we have no
+ conditional IFN for FIX_TRUNC_EXPR. */
+
+/* { dg-final { scan-tree-dump-times "Applying if-conversion" 0 "ifcvt" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-vectorize -fno-trapping-math -fdump-tree-ifcvt-stats" } */
+
+#include "ifcvt-fix-trunc-1.c"
+
+/* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */
void
f1(char f, char *g, char *h, char *l, char *n) {
- double i = d, j = 1.0 - f, k = j ? d : j;
- if (k == 1.0)
- i = 0.0;
- *l = *n = *g = *h = i * 0.5;
+ double j = 1.0 - f, k = j ? d : j;
+
+ char i = (k == 1.0) ? 10 : 50;
+ *l = *n = *g = *h = i;
}
void
/* Constructing an object cannot trap. */
return false;
+ case FIX_TRUNC_EXPR:
+ case VEC_PACK_FIX_TRUNC_EXPR:
+ case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
+ case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
+ /* The FIX_TRUNC family are always potentially trapping. */
+ return flag_trapping_math;
+
case COND_EXPR:
case VEC_COND_EXPR:
/* Whether *COND_EXPR can trap depends on whether the