aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-isel.cc
diff options
context:
space:
mode:
authorPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>2020-12-08 14:30:04 +0530
committerPrathamesh Kulkarni <prathamesh.kulkarni@linaro.org>2020-12-08 14:30:04 +0530
commit3a6e3ad38a17a03ee0139b49a0946e7b9ded1eb1 (patch)
tree7f183717821fc4422d514302c8950b6033ba2d53 /gcc/gimple-isel.cc
parente844c04e35ca2fe9ee2f758a720dd37cbe81e7ef (diff)
downloadgcc-3a6e3ad38a17a03ee0139b49a0946e7b9ded1eb1.zip
gcc-3a6e3ad38a17a03ee0139b49a0946e7b9ded1eb1.tar.gz
gcc-3a6e3ad38a17a03ee0139b49a0946e7b9ded1eb1.tar.bz2
gimple-isel: Fold x CMP y ? -1 : 0 to x CMP y [PR97872]
gcc/ 2020-12-08 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> PR target/97872 * gimple-isel.cc (gimple_expand_vec_cond_expr): Try to fold x CMP y ? -1 : 0 to x CMP y. gcc/testsuite/ 2020-12-08 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> PR target/97872 * gcc.target/arm/pr97872.c: New test.
Diffstat (limited to 'gcc/gimple-isel.cc')
-rw-r--r--gcc/gimple-isel.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/gimple-isel.cc b/gcc/gimple-isel.cc
index d79c212..1ab75e7 100644
--- a/gcc/gimple-isel.cc
+++ b/gcc/gimple-isel.cc
@@ -184,6 +184,20 @@ gimple_expand_vec_cond_expr (gimple_stmt_iterator *gsi,
tree op0_type = TREE_TYPE (op0);
tree op0a_type = TREE_TYPE (op0a);
+
+ /* Try to fold x CMP y ? -1 : 0 to x CMP y. */
+
+ if (integer_minus_onep (op1)
+ && integer_zerop (op2)
+ && TYPE_MODE (TREE_TYPE (lhs)) == TYPE_MODE (TREE_TYPE (op0))
+ && expand_vec_cmp_expr_p (op0a_type, op0_type, tcode))
+ {
+ tree conv_op = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (lhs), op0);
+ gassign *new_stmt = gimple_build_assign (lhs, conv_op);
+ gsi_replace (gsi, new_stmt, true);
+ return new_stmt;
+ }
+
if (used_vec_cond_exprs >= 2
&& (get_vcond_mask_icode (mode, TYPE_MODE (op0_type))
!= CODE_FOR_nothing)