From: Rafael Avila de Espindola Date: Thu, 8 May 2008 22:16:59 +0000 (+0000) Subject: tree-complex.c (expand_complex_div_wide): Don't create CONDs that trap. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=04b03edb56633f6e77d7834022d4e49a74f3cce5;p=gcc.git tree-complex.c (expand_complex_div_wide): Don't create CONDs that trap. * tree-complex.c (expand_complex_div_wide): Don't create CONDs that trap. * tree-gimple.c (is_gimple_condexpr): Check that the expression doesn't trap and that both operands are gimple values. (canonicalize_cond_expr_cond): Use is_gimple_condexpr. * gcc/tree-eh.c (tree_could_trap_p): Correctly detect if a comparison is a fp operation. * gcc/testsuite/gcc.dg/vect/vect-111.c: Rename to no-trapping-math-vect-111.c * gcc/testsuite/gcc.dg/vect/vect-ifcvt-11.c: Rename to no-trapping-math-vect-ifcvt-11.c * gcc/testsuite/gcc.dg/vect/vect-ifcvt-12.c: Rename to no-trapping-math-vect-ifcvt-12.c * gcc/testsuite/gcc.dg/vect/vect-ifcvt-13.c: Rename to no-trapping-math-vect-ifcvt-13.c * gcc/testsuite/gcc.dg/vect/vect-ifcvt-14.c: Rename to no-trapping-math-vect-ifcvt-14.c * gcc/testsuite/gcc.dg/vect/vect-ifcvt-15.c: Rename to no-trapping-math-vect-ifcvt-15.c From-SVN: r135093 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cb7ee2ec286..7d0a3afacaf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2008-05-08 Rafael Espindola + + * tree-complex.c (expand_complex_div_wide): Don't create CONDs that + trap. + * tree-gimple.c (is_gimple_condexpr): Check that the expression doesn't + trap and that both operands are gimple values. + (canonicalize_cond_expr_cond): Use is_gimple_condexpr. + * gcc/tree-eh.c (tree_could_trap_p): Correctly detect if a comparison + is a fp operation. + 2008-05-08 Richard Sandiford * read-rtl.c (join_c_conditions): Return the first string if the diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ff5d2cc92ff..9e3a1f148a9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2008-05-08 Rafael Espindola + + * gcc.dg/vect/vect-111.c: Rename to no-trapping-math-vect-111.c + * gcc.dg/vect/vect-ifcvt-11.c: Rename to no-trapping-math-vect-ifcvt-11.c + * gcc.dg/vect/vect-ifcvt-12.c: Rename to no-trapping-math-vect-ifcvt-12.c + * gcc.dg/vect/vect-ifcvt-13.c: Rename to no-trapping-math-vect-ifcvt-13.c + * gcc.dg/vect/vect-ifcvt-14.c: Rename to no-trapping-math-vect-ifcvt-14.c + * gcc.dg/vect/vect-ifcvt-15.c: Rename to no-trapping-math-vect-ifcvt-15.c + 2008-05-08 David Daney * lib/target-supports.exp (check_effective_target_sync_int_long): Add diff --git a/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-111.c b/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-111.c new file mode 100644 index 00000000000..413c7ef4226 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-111.c @@ -0,0 +1,38 @@ +/* { dg-require-effective-target vect_float } */ + +#include +#include "tree-vect.h" + +#define N 16 + +__attribute__ ((noinline)) int +main1 (void) +{ + int i; + float a[N]; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + + /* Condition in loop. */ + /* This loop is vectorized on platforms that support vect_condition. */ + for (i = 0; i < N; i++) + { + a[i] = (b[i] > 0 ? b[i] : 0); + } + + for (i = 0; i < N; i++) + { + if (a[i] != b[i]) + abort (); + } + return 0; +} + +int main (void) +{ + check_vect (); + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target powerpc*-*-* } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target i?86-*-* x86_64-*-* ia64-*-* } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-11.c b/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-11.c new file mode 100644 index 00000000000..560b5bc73df --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-11.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +extern void abort(void); + +int main () +{ + float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; + float B[N] = {0,0,42,42,42,0,0,0,0,0,42,42,42,42,42,0}; + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] >= MAX ? MAX : 0); + + /* check results: */ + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-12.c b/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-12.c new file mode 100644 index 00000000000..5f132b8ba81 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-12.c @@ -0,0 +1,32 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +extern void abort(void); + +int main () +{ + float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; + float B[N] = {0,0,0,42,42,0,0,0,0,0,42,42,42,42,42,0}; + int i, j; + + check_vect (); + for (i = 0; i < 16; i++) + A[i] = ( A[i] > MAX ? MAX : 0); + + /* check results: */ + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-13.c b/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-13.c new file mode 100644 index 00000000000..a5a59366bdc --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-13.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +extern void abort(void); + +int main () +{ + float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; + float B[N] = {42,42,42,0,0,42,42,42,42,42,0,0,0,0,0,42}; + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] <= MAX ? MAX : 0); + + /* check results: */ + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-14.c b/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-14.c new file mode 100644 index 00000000000..a5a59366bdc --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-14.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +extern void abort(void); + +int main () +{ + float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; + float B[N] = {42,42,42,0,0,42,42,42,42,42,0,0,0,0,0,42}; + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] <= MAX ? MAX : 0); + + /* check results: */ + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-15.c b/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-15.c new file mode 100644 index 00000000000..67d7ebe60c6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/no-trapping-math-vect-ifcvt-15.c @@ -0,0 +1,33 @@ +/* { dg-require-effective-target vect_condition } */ +/* { dg-require-effective-target vect_float } */ + +#include +#include +#include "tree-vect.h" + +#define N 16 +#define MAX 42 + +extern void abort(void); + +int main () +{ + float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; + float B[N] = {42,42,0,0,0,42,42,42,42,42,0,0,0,0,0,42}; + int i, j; + + check_vect (); + + for (i = 0; i < 16; i++) + A[i] = ( A[i] < MAX ? MAX : 0); + + /* check results: */ + for (i = 0; i < N; i++) + if (A[i] != B[i]) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-111.c b/gcc/testsuite/gcc.dg/vect/vect-111.c deleted file mode 100644 index 413c7ef4226..00000000000 --- a/gcc/testsuite/gcc.dg/vect/vect-111.c +++ /dev/null @@ -1,38 +0,0 @@ -/* { dg-require-effective-target vect_float } */ - -#include -#include "tree-vect.h" - -#define N 16 - -__attribute__ ((noinline)) int -main1 (void) -{ - int i; - float a[N]; - float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; - - /* Condition in loop. */ - /* This loop is vectorized on platforms that support vect_condition. */ - for (i = 0; i < N; i++) - { - a[i] = (b[i] > 0 ? b[i] : 0); - } - - for (i = 0; i < N; i++) - { - if (a[i] != b[i]) - abort (); - } - return 0; -} - -int main (void) -{ - check_vect (); - return main1 (); -} - -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target powerpc*-*-* } } } */ -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target i?86-*-* x86_64-*-* ia64-*-* } } } */ -/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-11.c b/gcc/testsuite/gcc.dg/vect/vect-ifcvt-11.c deleted file mode 100644 index 560b5bc73df..00000000000 --- a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-11.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-require-effective-target vect_condition } */ -/* { dg-require-effective-target vect_float } */ - -#include -#include -#include "tree-vect.h" - -#define N 16 -#define MAX 42 - -extern void abort(void); - -int main () -{ - float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; - float B[N] = {0,0,42,42,42,0,0,0,0,0,42,42,42,42,42,0}; - int i, j; - - check_vect (); - - for (i = 0; i < 16; i++) - A[i] = ( A[i] >= MAX ? MAX : 0); - - /* check results: */ - for (i = 0; i < N; i++) - if (A[i] != B[i]) - abort (); - - return 0; -} - -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ -/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-12.c b/gcc/testsuite/gcc.dg/vect/vect-ifcvt-12.c deleted file mode 100644 index 5f132b8ba81..00000000000 --- a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-12.c +++ /dev/null @@ -1,32 +0,0 @@ -/* { dg-require-effective-target vect_condition } */ -/* { dg-require-effective-target vect_float } */ - -#include -#include -#include "tree-vect.h" - -#define N 16 -#define MAX 42 - -extern void abort(void); - -int main () -{ - float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; - float B[N] = {0,0,0,42,42,0,0,0,0,0,42,42,42,42,42,0}; - int i, j; - - check_vect (); - for (i = 0; i < 16; i++) - A[i] = ( A[i] > MAX ? MAX : 0); - - /* check results: */ - for (i = 0; i < N; i++) - if (A[i] != B[i]) - abort (); - - return 0; -} - -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ -/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-13.c b/gcc/testsuite/gcc.dg/vect/vect-ifcvt-13.c deleted file mode 100644 index a5a59366bdc..00000000000 --- a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-13.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-require-effective-target vect_condition } */ -/* { dg-require-effective-target vect_float } */ - -#include -#include -#include "tree-vect.h" - -#define N 16 -#define MAX 42 - -extern void abort(void); - -int main () -{ - float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; - float B[N] = {42,42,42,0,0,42,42,42,42,42,0,0,0,0,0,42}; - int i, j; - - check_vect (); - - for (i = 0; i < 16; i++) - A[i] = ( A[i] <= MAX ? MAX : 0); - - /* check results: */ - for (i = 0; i < N; i++) - if (A[i] != B[i]) - abort (); - - return 0; -} - -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ -/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-14.c b/gcc/testsuite/gcc.dg/vect/vect-ifcvt-14.c deleted file mode 100644 index a5a59366bdc..00000000000 --- a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-14.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-require-effective-target vect_condition } */ -/* { dg-require-effective-target vect_float } */ - -#include -#include -#include "tree-vect.h" - -#define N 16 -#define MAX 42 - -extern void abort(void); - -int main () -{ - float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; - float B[N] = {42,42,42,0,0,42,42,42,42,42,0,0,0,0,0,42}; - int i, j; - - check_vect (); - - for (i = 0; i < 16; i++) - A[i] = ( A[i] <= MAX ? MAX : 0); - - /* check results: */ - for (i = 0; i < N; i++) - if (A[i] != B[i]) - abort (); - - return 0; -} - -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ -/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-15.c b/gcc/testsuite/gcc.dg/vect/vect-ifcvt-15.c deleted file mode 100644 index 67d7ebe60c6..00000000000 --- a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-15.c +++ /dev/null @@ -1,33 +0,0 @@ -/* { dg-require-effective-target vect_condition } */ -/* { dg-require-effective-target vect_float } */ - -#include -#include -#include "tree-vect.h" - -#define N 16 -#define MAX 42 - -extern void abort(void); - -int main () -{ - float A[N] = {36,39,42,45,43,32,21,12,23,34,45,56,67,78,89,11}; - float B[N] = {42,42,0,0,0,42,42,42,42,42,0,0,0,0,0,42}; - int i, j; - - check_vect (); - - for (i = 0; i < 16; i++) - A[i] = ( A[i] < MAX ? MAX : 0); - - /* check results: */ - for (i = 0; i < N; i++) - if (A[i] != B[i]) - abort (); - - return 0; -} - -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ -/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c index 4703e78d22d..8d680dfa6bf 100644 --- a/gcc/tree-complex.c +++ b/gcc/tree-complex.c @@ -1047,22 +1047,30 @@ expand_complex_div_wide (block_stmt_iterator *bsi, tree inner_type, tree ar, tree ai, tree br, tree bi, enum tree_code code) { - tree rr, ri, ratio, div, t1, t2, tr, ti, cond; + tree rr, ri, ratio, div, t1, t2, tr, ti, compare; basic_block bb_cond, bb_true, bb_false, bb_join; /* Examine |br| < |bi|, and branch. */ t1 = gimplify_build1 (bsi, ABS_EXPR, inner_type, br); t2 = gimplify_build1 (bsi, ABS_EXPR, inner_type, bi); - cond = fold_build2 (LT_EXPR, boolean_type_node, t1, t2); - STRIP_NOPS (cond); + compare = fold_build2 (LT_EXPR, boolean_type_node, t1, t2); + STRIP_NOPS (compare); bb_cond = bb_true = bb_false = bb_join = NULL; rr = ri = tr = ti = NULL; - if (!TREE_CONSTANT (cond)) + if (!TREE_CONSTANT (compare)) { edge e; + tree cond, tmp; - cond = build3 (COND_EXPR, void_type_node, cond, NULL_TREE, NULL_TREE); + tmp = create_tmp_var (boolean_type_node, NULL); + cond = build_gimple_modify_stmt (tmp, compare); + if (gimple_in_ssa_p (cfun)) + tmp = make_ssa_name (tmp, cond); + GIMPLE_STMT_OPERAND (cond, 0) = tmp; + bsi_insert_before (bsi, cond, BSI_SAME_STMT); + + cond = build3 (COND_EXPR, void_type_node, tmp, NULL_TREE, NULL_TREE); bsi_insert_before (bsi, cond, BSI_SAME_STMT); /* Split the original block, and create the TRUE and FALSE blocks. */ @@ -1098,7 +1106,7 @@ expand_complex_div_wide (block_stmt_iterator *bsi, tree inner_type, ti = (ai * ratio) - ar; tr = tr / div; ti = ti / div; */ - if (bb_true || integer_nonzerop (cond)) + if (bb_true || integer_nonzerop (compare)) { if (bb_true) { @@ -1137,7 +1145,7 @@ expand_complex_div_wide (block_stmt_iterator *bsi, tree inner_type, ti = b - (a * ratio); tr = tr / div; ti = ti / div; */ - if (bb_false || integer_zerop (cond)) + if (bb_false || integer_zerop (compare)) { if (bb_false) { diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 06e4b5a9d07..9428e38c54e 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -1896,7 +1896,10 @@ tree_could_trap_p (tree expr) || TREE_CODE_CLASS (code) == tcc_binary) { t = TREE_TYPE (expr); - fp_operation = FLOAT_TYPE_P (t); + if (COMPARISON_CLASS_P (expr)) + fp_operation = FLOAT_TYPE_P (TREE_TYPE (TREE_OPERAND (expr, 0))); + else + fp_operation = FLOAT_TYPE_P (t); if (fp_operation) { honor_nans = flag_trapping_math && !flag_finite_math_only; diff --git a/gcc/tree-gimple.c b/gcc/tree-gimple.c index 433c294039b..101dfd17c2b 100644 --- a/gcc/tree-gimple.c +++ b/gcc/tree-gimple.c @@ -155,7 +155,10 @@ is_gimple_lvalue (tree t) bool is_gimple_condexpr (tree t) { - return (is_gimple_val (t) || COMPARISON_CLASS_P (t)); + return (is_gimple_val (t) || (COMPARISON_CLASS_P (t) + && !tree_could_trap_p (t) + && is_gimple_val (TREE_OPERAND (t, 0)) + && is_gimple_val (TREE_OPERAND (t, 1)))); } /* Return true if T is something whose address can be taken. */ @@ -648,12 +651,7 @@ canonicalize_cond_expr_cond (tree t) TREE_OPERAND (top0, 0), TREE_OPERAND (top0, 1)); } - /* A valid conditional for a COND_EXPR is either a gimple value - or a comparison with two gimple value operands. */ - if (is_gimple_val (t) - || (COMPARISON_CLASS_P (t) - && is_gimple_val (TREE_OPERAND (t, 0)) - && is_gimple_val (TREE_OPERAND (t, 1)))) + if (is_gimple_condexpr (t)) return t; return NULL_TREE;