+2018-11-28 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/88189
+ * config/i386/i386.c (ix86_expand_sse_movcc): Handle DFmode and
+ SFmode using sse4_1_blendvs[sd] with TARGET_SSE4_1. Formatting fixes.
+ * config/i386/sse.md (sse4_1_blendv<ssemodesuffix>): New pattern.
+
2018-11-27 Martin Liska <mliska@suse.cz>
* gcov.c (generate_results): Append current_working_directory
{
emit_insn (gen_rtx_SET (dest, cmp));
}
- else if (op_false == CONST0_RTX (mode)
- && !maskcmp)
+ else if (op_false == CONST0_RTX (mode) && !maskcmp)
{
op_true = force_reg (mode, op_true);
x = gen_rtx_AND (mode, cmp, op_true);
emit_insn (gen_rtx_SET (dest, x));
}
- else if (op_true == CONST0_RTX (mode)
- && !maskcmp)
+ else if (op_true == CONST0_RTX (mode) && !maskcmp)
{
op_false = force_reg (mode, op_false);
x = gen_rtx_NOT (mode, cmp);
emit_insn (gen_rtx_SET (dest, x));
}
else if (INTEGRAL_MODE_P (mode) && op_true == CONSTM1_RTX (mode)
- && !maskcmp)
+ && !maskcmp)
{
op_false = force_reg (mode, op_false);
x = gen_rtx_IOR (mode, cmp, op_false);
emit_insn (gen_rtx_SET (dest, x));
}
- else if (TARGET_XOP
- && !maskcmp)
+ else if (TARGET_XOP && !maskcmp)
{
op_true = force_reg (mode, op_true);
if (TARGET_SSE4_1)
gen = gen_sse4_1_blendvpd;
break;
+ case E_SFmode:
+ if (TARGET_SSE4_1)
+ {
+ gen = gen_sse4_1_blendvss;
+ op_true = force_reg (mode, op_true);
+ }
+ break;
+ case E_DFmode:
+ if (TARGET_SSE4_1)
+ {
+ gen = gen_sse4_1_blendvsd;
+ op_true = force_reg (mode, op_true);
+ }
+ break;
case E_V16QImode:
case E_V8HImode:
case E_V4SImode:
(set_attr "btver2_decode" "vector,vector,vector")
(set_attr "mode" "<MODE>")])
+;; Also define scalar versions. These are used for conditional move.
+;; Using subregs into vector modes causes register allocation lossage.
+;; These patterns do not allow memory operands because the native
+;; instructions read the full 128-bits.
+
+(define_insn "sse4_1_blendv<ssemodesuffix>"
+ [(set (match_operand:MODEF 0 "register_operand" "=Yr,*x,x")
+ (unspec:MODEF
+ [(match_operand:MODEF 1 "register_operand" "0,0,x")
+ (match_operand:MODEF 2 "register_operand" "Yr,*x,x")
+ (match_operand:MODEF 3 "register_operand" "Yz,Yz,x")]
+ UNSPEC_BLENDV))]
+ "TARGET_SSE4_1"
+{
+ if (get_attr_mode (insn) == MODE_V4SF)
+ return (which_alternative == 2
+ ? "vblendvps\t{%3, %2, %1, %0|%0, %1, %2, %3}"
+ : "blendvps\t{%3, %2, %0|%0, %2, %3}");
+ else
+ return (which_alternative == 2
+ ? "vblendv<ssevecmodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
+ : "blendv<ssevecmodesuffix>\t{%3, %2, %0|%0, %2, %3}");
+}
+ [(set_attr "isa" "noavx,noavx,avx")
+ (set_attr "type" "ssemov")
+ (set_attr "length_immediate" "1")
+ (set_attr "prefix_data16" "1,1,*")
+ (set_attr "prefix_extra" "1")
+ (set_attr "prefix" "orig,orig,vex")
+ (set_attr "btver2_decode" "vector,vector,vector")
+ (set (attr "mode")
+ (cond [(match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
+ (const_string "V4SF")
+ (match_test "TARGET_AVX")
+ (const_string "<ssevecmode>")
+ (match_test "optimize_function_for_size_p (cfun)")
+ (const_string "V4SF")
+ ]
+ (const_string "<ssevecmode>")))])
+
(define_insn "<sse4_1>_dp<ssemodesuffix><avxsizesuffix>"
[(set (match_operand:VF_128_256 0 "register_operand" "=Yr,*x,x")
(unspec:VF_128_256
2018-11-28 Jakub Jelinek <jakub@redhat.com>
+ PR target/88189
+ * gcc.target/i386/sse4_1-pr88189-1.c: New test.
+ * gcc.target/i386/sse4_1-pr88189-2.c: New test.
+ * gcc.target/i386/avx-pr88189-1.c: New test.
+ * gcc.target/i386/avx-pr88189-2.c: New test.
+
PR c++/87476
* g++.dg/cpp0x/pr87476-1.C: New test.
* g++.dg/cpp0x/pr87476-2.C: New test.
--- /dev/null
+/* { dg-do run } */
+/* { dg-require-effective-target avx } */
+/* { dg-options "-O2 -mavx -mfpmath=sse" } */
+
+#define CHECK_H "avx-check.h"
+#define TEST avx_test
+
+#include "sse4_1-pr88189-1.c"
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx -mfpmath=sse" } */
+
+__attribute__((noipa)) double
+f1 (double a, double b)
+{
+ return a < 0 ? a : b;
+}
+
+__attribute__((noipa)) float
+f2 (float a, float b)
+{
+ return a < 0 ? a : b;
+}
+
+/* { dg-final { scan-assembler-times "vblendvp\[sd]" 2 } } */
--- /dev/null
+/* { dg-do run } */
+/* { dg-require-effective-target sse4 } */
+/* { dg-options "-O2 -msse4.1 -mfpmath=sse" } */
+
+#ifndef CHECK_H
+#define CHECK_H "sse4_1-check.h"
+#endif
+
+#ifndef TEST
+#define TEST sse4_1_test
+#endif
+
+#include CHECK_H
+
+__attribute__((noipa)) double
+f1 (double a, double b)
+{
+ return a < 0 ? a : b;
+}
+
+__attribute__((noipa)) float
+f2 (float a, float b)
+{
+ return a < 0 ? a : b;
+}
+
+static void
+TEST (void)
+{
+ if (f1 (5.0, 7.0) != 7.0
+ || f1 (-2.0, 7.0) != -2.0
+ || f2 (1.0f, 2.0f) != 2.0f
+ || f2 (-1.0f, -3.0f) != -1.0f)
+ abort ();
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -msse4.1 -mno-avx -mfpmath=sse" } */
+
+__attribute__((noipa)) double
+f1 (double a, double b)
+{
+ return a < 0 ? a : b;
+}
+
+__attribute__((noipa)) float
+f2 (float a, float b)
+{
+ return a < 0 ? a : b;
+}
+
+/* { dg-final { scan-assembler-times "blendvp\[sd]" 2 } } */