+2018-04-03 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/85156
+ * builtins.c (fold_builtin_expect): Use save_expr on arg1 to avoid
+ evaluating the argument multiple times.
+
2018-04-03 Bill Schmidt <wschmidt@linux.ibm.com>
* config/rs6000/emmintrin.h (_mm_cvtpd_epi32): Use __vector rather
{
tree op0 = TREE_OPERAND (inner, 0);
tree op1 = TREE_OPERAND (inner, 1);
+ arg1 = save_expr (arg1);
op0 = build_builtin_expect_predicate (loc, op0, arg1, arg2);
op1 = build_builtin_expect_predicate (loc, op1, arg1, arg2);
+2018-04-03 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/85156
+ * c-c++-common/pr85156.c: New test.
+ * gcc.c-torture/execute/pr85156.c: New test.
+
2018-04-03 Bill Schmidt <wschmidt@linux.ibm.com>
* gcc.target/powerpc/powerpc.exp: Add .C suffix for main loop.
--- /dev/null
+/* PR tree-optimization/85156 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -g" } */
+
+int a, b;
+
+int
+foo (void)
+{
+ return __builtin_expect (a ? b != 0 : 0, ({ 1; }));
+}
--- /dev/null
+/* PR tree-optimization/85156 */
+
+int x, y;
+
+__attribute__((noipa)) int
+foo (int z)
+{
+ if (__builtin_expect (x ? y != 0 : 0, z++))
+ return 7;
+ return z;
+}
+
+int
+main ()
+{
+ x = 1;
+ asm volatile ("" : "+m" (x), "+m" (y));
+ if (foo (10) != 11)
+ __builtin_abort ();
+ return 0;
+}