--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-sccp-details" } */
+/* { dg-final { scan-tree-dump-times {final value replacement} 8 "sccp" } } */
+
+unsigned int
+__attribute__((noipa))
+foo (unsigned int tmp)
+{
+ for (int bit = 0; bit < 64; bit++)
+ tmp &= 11304;
+ return tmp;
+}
+
+unsigned int
+__attribute__((noipa))
+foo1 (unsigned int tmp)
+{
+ for (int bit = 63; bit >= 0; bit -=3)
+ tmp &= 11304;
+ return tmp;
+}
+
+unsigned int
+__attribute__((noipa))
+foo2 (unsigned int tmp)
+{
+ for (int bit = 0; bit < 64; bit++)
+ tmp |= 11304;
+ return tmp;
+}
+
+unsigned int
+__attribute__((noipa))
+foo3 (unsigned int tmp)
+{
+ for (int bit = 63; bit >= 0; bit -=3)
+ tmp |= 11304;
+ return tmp;
+}
+
+unsigned int
+__attribute__((noipa))
+foo4 (unsigned int tmp)
+{
+ for (int bit = 0; bit < 64; bit++)
+ tmp ^= 11304;
+ return tmp;
+}
+
+unsigned int
+__attribute__((noipa))
+foo5 (unsigned int tmp)
+{
+ for (int bit = 0; bit < 63; bit++)
+ tmp ^= 11304;
+ return tmp;
+}
+
+unsigned int
+__attribute__((noipa))
+f (unsigned int tmp, int bit)
+{
+ unsigned int res = tmp;
+ for (int i = 0; i < bit; i++)
+ res &= 11304;
+ return res;
+}
+
+unsigned int
+__attribute__((noipa))
+f1 (unsigned int tmp, int bit)
+{
+ unsigned int res = tmp;
+ for (int i = 0; i < bit; i++)
+ res |= 11304;
+ return res;
+}
+
+unsigned int
+__attribute__((noipa))
+f2 (unsigned int tmp, int bit)
+{
+ unsigned int res = tmp;
+ for (int i = 0; i < bit; i++)
+ res ^= 11304;
+ return res;
+}
match_op[0] = gimple_assign_rhs1 (def);
match_op[1] = gimple_assign_rhs2 (def);
+ if (expr_invariant_in_loop_p (loop, match_op[1]))
+ std::swap (match_op[0], match_op[1]);
+
if (TREE_CODE (match_op[1]) != SSA_NAME
|| !expr_invariant_in_loop_p (loop, match_op[0])
|| !(header_phi = dyn_cast <gphi *> (SSA_NAME_DEF_STMT (match_op[1])))