/* !A ? B : C -> A ? C : B. */
(simplify
(cnd (logical_inverted_value truth_valued_p@0) @1 @2)
- (cnd @0 @2 @1)))
+ /* For CONDs, don't handle signed values here. */
+ (if (cnd == VEC_COND_EXPR
+ || TYPE_UNSIGNED (TREE_TYPE (@0)))
+ (cnd @0 @2 @1))))
/* abs/negative simplifications moved from fold_cond_expr_with_comparison.
(cond @0 @1 @2)
(with { bool wascmp; }
(if (INTEGRAL_TYPE_P (type)
+ && TYPE_UNSIGNED (TREE_TYPE (@0))
&& bitwise_inverted_equal_p (@1, @2, wascmp)
&& (!wascmp || TYPE_PRECISION (type) == 1))
(if ((!TYPE_UNSIGNED (type) && TREE_CODE (type) == BOOLEAN_TYPE)
--- /dev/null
+/* PR tree-optimization/114666 */
+/* We used to miscompile this to be always aborting
+ due to the use of the signed 1bit into the COND_EXPR. */
+
+struct {
+ signed a : 1;
+} b = {-1};
+char c;
+int main()
+{
+ if ((b.a ^ 1UL) < 3)
+ __builtin_abort();
+}