@0)
/* zero_one_valued_p will match when a value is known to be either
- 0 or 1 including constants 0 or 1. */
+ 0 or 1 including constants 0 or 1.
+ Signed 1-bits includes -1 so they cannot match here. */
(match zero_one_valued_p
@0
- (if (INTEGRAL_TYPE_P (type) && wi::leu_p (tree_nonzero_bits (@0), 1))))
+ (if (INTEGRAL_TYPE_P (type)
+ && (TYPE_UNSIGNED (type)
+ || TYPE_PRECISION (type) > 1)
+ && wi::leu_p (tree_nonzero_bits (@0), 1))))
(match zero_one_valued_p
- truth_valued_p@0)
+ truth_valued_p@0
+ (if (INTEGRAL_TYPE_P (type)
+ && (TYPE_UNSIGNED (type)
+ || TYPE_PRECISION (type) > 1))))
/* Transform { 0 or 1 } * { 0 or 1 } into { 0 or 1 } & { 0 or 1 }. */
(simplify
--- /dev/null
+struct s
+{
+ int t : 1;
+};
+
+int f(struct s t, int a, int b) __attribute__((noinline));
+int f(struct s t, int a, int b)
+{
+ int bd = t.t;
+ if (bd) a|=b;
+ return a;
+}
+
+int main(void)
+{
+ struct s t;
+ for(int i = -1;i <= 1; i++)
+ {
+ int a = 0x10;
+ int b = 0x0f;
+ int c = a | b;
+ struct s t = {i};
+ int r = f(t, a, b);
+ int exp = (i != 0) ? a | b : a;
+ if (exp != r)
+ __builtin_abort();
+ }
+}
--- /dev/null
+struct s
+{
+ int t : 1;
+ int t1 : 1;
+};
+
+int f(struct s t) __attribute__((noinline));
+int f(struct s t)
+{
+ int c = t.t;
+ int d = t.t1;
+ if (c > d)
+ t.t = d;
+ else
+ t.t = c;
+ return t.t;
+}
+
+int main(void)
+{
+ struct s t;
+ for(int i = -1;i <= 0; i++)
+ {
+ for(int j = -1;j <= 0; j++)
+ {
+ struct s t = {i, j};
+ int r = f(t);
+ int exp = i < j ? i : j;
+ if (exp != r)
+ __builtin_abort();
+ }
+ }
+}