/* For CONDs, don't handle signed values here. */
(if (cnd == VEC_COND_EXPR
|| TYPE_UNSIGNED (TREE_TYPE (@0)))
- (cnd @0 @2 @1))))
+ (cnd @0 @2 @1)))
+
+ /* A == CST ? A : CST -> CST. */
+ (simplify
+ (cnd (eq @0 CONSTANT_CLASS_P@1) (nop_convert? @0) CONSTANT_CLASS_P@2)
+ (if (ANY_INTEGRAL_TYPE_P (type)
+ && operand_equal_p (@1, @2))
+ (convert @1)))
+
+ /* A != CST ? CST : A -> CST. */
+ (simplify
+ (cnd (ne @0 CONSTANT_CLASS_P@1) CONSTANT_CLASS_P@2 (nop_convert? @0))
+ (if (ANY_INTEGRAL_TYPE_P (type)
+ && operand_equal_p (@1, @2))
+ (convert @1))))
/* abs/negative simplifications moved from fold_cond_expr_with_comparison.
--- /dev/null
+// PR c++/124663
+// { dg-do compile }
+// { dg-options "-O2 -fdump-tree-forwprop3-raw" }
+
+#define vector __attribute__((vector_size(4*sizeof(int))))
+void f(vector int *a)
+{
+ vector int cst = {1,2,3,4};
+ vector int t = (*a == cst);
+ *a = (t ? *a : cst);
+}
+
+// { dg-final { scan-tree-dump-not "_expr" "forwprop3" } }