&& !POINTER_TYPE_P (TREE_TYPE (@0))
&& TREE_CODE (TREE_TYPE (@0)) != OFFSET_TYPE
&& TYPE_PRECISION (TREE_TYPE (@0)) > TYPE_PRECISION (type))
- (bitop:type (convert @0) (convert @1)))))
+ (bitop:type (convert @0) (convert @1))
+ /* Similar as above, but the outer and inner most types match
+ and it was widening cast; replacing 2 casts with only one. */
+ (if (GIMPLE
+ && INTEGRAL_TYPE_P (type)
+ && INTEGRAL_TYPE_P (TREE_TYPE (@0))
+ && types_match (type, TREE_TYPE (@0))
+ && TYPE_PRECISION (TREE_TYPE (@2)) > TYPE_PRECISION (type))
+ (bitop:type @0 (convert @1))))))
(for bitop (bit_and bit_ior)
rbitop (bit_ior bit_and)
/* PR tree-optimization/83843 */
/* { dg-do run } */
/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */
-/* { dg-final { scan-tree-dump-times "Merging successful" 3 "store-merging" { target { store_merge && { ! arm*-*-* } } } } } */
+/* xfailed after PR 122845, see PR 123541 ( */
+/* { dg-final { scan-tree-dump-times "Merging successful" 3 "store-merging" { target { store_merge && { ! arm*-*-* } } xfail *-*-* } } } */
__attribute__((noipa)) void
foo (unsigned char *buf, unsigned char *tab)
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized-raw" } */
+/* PR tree-optimization/122845 */
+
+struct s1
+{
+ signed f1:3;
+};
+struct s1 p;
+void f(void)
+{
+ p.f1 ^= -47;
+ p.f1 ^= -47;
+}
+
+/* There should be no gimple stmts left except for return.
+ That is the ^ has been optimized away. */
+/* { dg-final { scan-tree-dump-not "gimple_assign <" "optimized" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized-raw" } */
+/* PR tree-optimization/122845 */
+
+int f(signed char a, int b)
+{
+ int aa = a;
+ int bb = b;
+ aa &= bb;
+ signed char t = aa;
+ aa = t;
+ aa &= bb;
+ t = aa;
+ return t;
+}
+
+/* There should be only 1 bit_and_expr left as both ands are the same. */
+/* { dg-final { scan-tree-dump-times "bit_and_expr, " 1 "optimized" } } */