aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-10-15 09:48:10 +0200
committerRichard Biener <rguenth@gcc.gnu.org>2024-10-15 11:06:30 +0200
commit79b881df72c946f2ba61879c36ae93b0cb974617 (patch)
treee7cbbf31c29bb73228d479ad49b74ed753b1de2f
parent8af474aa5d5efdda7def6cdcec3f246df2c7026a (diff)
downloadgcc-79b881df72c946f2ba61879c36ae93b0cb974617.zip
gcc-79b881df72c946f2ba61879c36ae93b0cb974617.tar.gz
gcc-79b881df72c946f2ba61879c36ae93b0cb974617.tar.bz2
middle-end/117137 - expansion issue with vector equality compares
When expanding a COND_EXPR with a vector equality compare as condition expand_cond_expr_using_cmove fails to properly go the cbranch path. I failed to massage it's twisted logic so the simple fix is to make sure to expand a vector condition separately which also generates the expected code for the testcase: ptest %xmm0, %xmm0 cmovne %edi, %eax PR middle-end/117137 * expr.cc (expand_cond_expr_using_cmove): Make sure to expand vector comparisons separately. * gcc.dg/torture/pr117137.c: New testcase.
-rw-r--r--gcc/expr.cc6
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr117137.c13
2 files changed, 17 insertions, 2 deletions
diff --git a/gcc/expr.cc b/gcc/expr.cc
index 7a471f2..da486cf 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -9524,7 +9524,8 @@ expand_cond_expr_using_cmove (tree treeop0 ATTRIBUTE_UNUSED,
EXPAND_NORMAL);
if (TREE_CODE (treeop0) == SSA_NAME
- && (srcstmt = get_def_for_expr_class (treeop0, tcc_comparison)))
+ && (srcstmt = get_def_for_expr_class (treeop0, tcc_comparison))
+ && !VECTOR_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (srcstmt))))
{
type = TREE_TYPE (gimple_assign_rhs1 (srcstmt));
enum tree_code cmpcode = gimple_assign_rhs_code (srcstmt);
@@ -9534,7 +9535,8 @@ expand_cond_expr_using_cmove (tree treeop0 ATTRIBUTE_UNUSED,
unsignedp = TYPE_UNSIGNED (type);
comparison_code = convert_tree_comp_to_rtx (cmpcode, unsignedp);
}
- else if (COMPARISON_CLASS_P (treeop0))
+ else if (COMPARISON_CLASS_P (treeop0)
+ && !VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (treeop0, 0))))
{
type = TREE_TYPE (TREE_OPERAND (treeop0, 0));
enum tree_code cmpcode = TREE_CODE (treeop0);
diff --git a/gcc/testsuite/gcc.dg/torture/pr117137.c b/gcc/testsuite/gcc.dg/torture/pr117137.c
new file mode 100644
index 0000000..b6ce78d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr117137.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-msse4" { target { x86_64-*-* i?86-*-* } } } */
+
+long x[2];
+
+int
+foo (int c)
+{
+ long x0 = x[0], x1 = x[1];
+ int t = x0 != 0 | x1 != 0;
+ c *= t;
+ return c;
+}