Hi! The BINARY_P predicate is true not just for arithmetic binary ops, but for relational ones too; for the latter, we must not call simplify_gen_binary, but simplify_gen_relational instead.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-11-13 Jakub Jelinek <ja...@redhat.com> PR rtl-optimization/87918 * simplify-rtx.c (simplify_merge_mask): For COMPARISON_P, use simplify_gen_relational rather than simplify_gen_binary. * gcc.target/i386/pr87918.c: New test. --- gcc/simplify-rtx.c.jj 2018-11-08 18:07:08.716852316 +0100 +++ gcc/simplify-rtx.c 2018-11-12 18:20:22.196580659 +0100 @@ -5647,9 +5647,19 @@ simplify_merge_mask (rtx x, rtx mask, in rtx top0 = simplify_merge_mask (XEXP (x, 0), mask, op); rtx top1 = simplify_merge_mask (XEXP (x, 1), mask, op); if (top0 || top1) - return simplify_gen_binary (GET_CODE (x), GET_MODE (x), - top0 ? top0 : XEXP (x, 0), - top1 ? top1 : XEXP (x, 1)); + { + if (COMPARISON_P (x)) + return simplify_gen_relational (GET_CODE (x), GET_MODE (x), + GET_MODE (XEXP (x, 0)) != VOIDmode + ? GET_MODE (XEXP (x, 0)) + : GET_MODE (XEXP (x, 1)), + top0 ? top0 : XEXP (x, 0), + top1 ? top1 : XEXP (x, 1)); + else + return simplify_gen_binary (GET_CODE (x), GET_MODE (x), + top0 ? top0 : XEXP (x, 0), + top1 ? top1 : XEXP (x, 1)); + } } if (GET_RTX_CLASS (GET_CODE (x)) == RTX_TERNARY && VECTOR_MODE_P (GET_MODE (XEXP (x, 0))) --- gcc/testsuite/gcc.target/i386/pr87918.c.jj 2018-11-12 18:17:49.075088126 +0100 +++ gcc/testsuite/gcc.target/i386/pr87918.c 2018-11-12 18:18:36.239316318 +0100 @@ -0,0 +1,14 @@ +/* PR rtl-optimization/87918 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -msse2" } */ + +#include <x86intrin.h> + +__m128 b, c, d; + +void +foo (float f) +{ + c = _mm_set_ss (f); + d = _mm_cmple_ss (c, b); +} Jakub