aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/match.pd22
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr103417.c11
2 files changed, 20 insertions, 13 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index 5adcd6b..39fd77d 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -5214,20 +5214,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
/* Transform comparisons of the form (X & Y) CMP 0 to X CMP2 Z
where ~Y + 1 == pow2 and Z = ~Y. */
(for cst (VECTOR_CST INTEGER_CST)
- (for cmp (le eq ne ge gt)
- icmp (le le gt le gt)
- (simplify
- (cmp (bit_and:c@2 @0 cst@1) integer_zerop)
- (with { tree csts = bitmask_inv_cst_vector_p (@1); }
- (switch
- (if (csts && TYPE_UNSIGNED (TREE_TYPE (@1))
- && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2)))
- (icmp @0 { csts; }))
- (if (csts && !TYPE_UNSIGNED (TREE_TYPE (@1))
- && (cmp == EQ_EXPR || cmp == NE_EXPR)
- && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2)))
+ (for cmp (eq ne)
+ icmp (le gt)
+ (simplify
+ (cmp (bit_and:c@2 @0 cst@1) integer_zerop)
+ (with { tree csts = bitmask_inv_cst_vector_p (@1); }
+ (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2)))
+ (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
+ (icmp @0 { csts; })
(with { tree utype = unsigned_type_for (TREE_TYPE (@1)); }
- (icmp (convert:utype @0) { csts; }))))))))
+ (icmp (convert:utype @0) { csts; }))))))))
/* -A CMP -B -> B CMP A. */
(for cmp (tcc_comparison)
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr103417.c b/gcc/testsuite/gcc.c-torture/execute/pr103417.c
new file mode 100644
index 0000000..0fef890
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr103417.c
@@ -0,0 +1,11 @@
+/* PR tree-optimization/103417 */
+
+struct { int a : 8; int b : 24; } c = { 0, 1 };
+
+int
+main ()
+{
+ if (c.b && !c.b)
+ __builtin_abort ();
+ return 0;
+}