@@ -3752,6 +3752,27 @@ ix86_expand_sse_cmp (rtx dest, enum rtx_code code, rtx cmp_op0, rtx cmp_op1,
return dest;
}
+/* Emit x86 binary operand CODE in mode MODE for SSE vector
+ instructions that can be performed using GP registers. */
+
+static void
+ix86_emit_vec_binop (enum rtx_code code, machine_mode mode,
+ rtx dst, rtx src1, rtx src2)
+{
+ rtx tmp;
+
+ tmp = gen_rtx_SET (dst, gen_rtx_fmt_ee (code, mode, src1, src2));
+
+ if (GET_MODE_SIZE (mode) <= GET_MODE_SIZE (SImode)
+ && GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
+ {
+ rtx clob = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
+ tmp = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, tmp, clob));
+ }
+
+ emit_insn (tmp);
+}
+
/* Expand DEST = CMP ? OP_TRUE : OP_FALSE into a sequence of logical
operations. This is used for both scalar and vector conditional moves. */
@@ -3820,23 +3841,20 @@ ix86_expand_sse_movcc (rtx dest, rtx cmp, rtx op_true, rtx op_false)
else if (op_false == CONST0_RTX (mode))
{
op_true = force_reg (mode, op_true);
- x = gen_rtx_AND (mode, cmp, op_true);
- emit_insn (gen_rtx_SET (dest, x));
+ ix86_emit_vec_binop (AND, mode, dest, cmp, op_true);
return;
}
else if (op_true == CONST0_RTX (mode))
{
op_false = force_reg (mode, op_false);
x = gen_rtx_NOT (mode, cmp);
- x = gen_rtx_AND (mode, x, op_false);
- emit_insn (gen_rtx_SET (dest, x));
+ ix86_emit_vec_binop (AND, mode, dest, x, op_false);
return;
}
else if (INTEGRAL_MODE_P (mode) && op_true == CONSTM1_RTX (mode))
{
op_false = force_reg (mode, op_false);
- x = gen_rtx_IOR (mode, cmp, op_false);
- emit_insn (gen_rtx_SET (dest, x));
+ ix86_emit_vec_binop (IOR, mode, dest, cmp, op_false);
return;
}
else if (TARGET_XOP)
@@ -4010,15 +4028,12 @@ ix86_expand_sse_movcc (rtx dest, rtx cmp, rtx op_true, rtx op_false)
else
t3 = dest;
- x = gen_rtx_AND (mode, op_true, cmp);
- emit_insn (gen_rtx_SET (t2, x));
+ ix86_emit_vec_binop (AND, mode, t2, op_true, cmp);
x = gen_rtx_NOT (mode, cmp);
- x = gen_rtx_AND (mode, x, op_false);
- emit_insn (gen_rtx_SET (t3, x));
+ ix86_emit_vec_binop (AND, mode, t3, x, op_false);
- x = gen_rtx_IOR (mode, t3, t2);
- emit_insn (gen_rtx_SET (dest, x));
+ ix86_emit_vec_binop (IOR, mode, dest, t3, t2);
}
}
@@ -20733,7 +20748,7 @@ expand_vec_perm_pshufb2 (struct expand_vec_perm_d *d)
op = d->target;
if (d->vmode != mode)
op = gen_reg_rtx (mode);
- emit_insn (gen_rtx_SET (op, gen_rtx_IOR (mode, l, h)));
+ ix86_emit_vec_binop (IOR, mode, op, l, h);
if (op != d->target)
emit_move_insn (d->target, gen_lowpart (d->vmode, op));
@@ -1634,7 +1634,7 @@
"operands[2] = force_reg (<MODE>mode, CONST0_RTX (<MODE>mode));")
(define_insn "negv2qi2"
- [(set (match_operand:V2QI 0 "register_operand" "=Q,&Yw")
+ [(set (match_operand:V2QI 0 "register_operand" "=?Q,&Yw")
(neg:V2QI
(match_operand:V2QI 1 "register_operand" "0,Yw")))
(clobber (reg:CC FLAGS_REG))]
@@ -1740,7 +1740,7 @@
(set_attr "mode" "TI")])
(define_insn "<insn>v2qi3"
- [(set (match_operand:V2QI 0 "register_operand" "=Q,x,Yw")
+ [(set (match_operand:V2QI 0 "register_operand" "=?Q,x,Yw")
(plusminus:V2QI
(match_operand:V2QI 1 "register_operand" "<comm>0,0,Yw")
(match_operand:V2QI 2 "register_operand" "Q,x,Yw")))
@@ -2587,7 +2587,7 @@
(match_operand:VI_16_32 5 "register_operand")])
(match_operand:VI_16_32 1)
(match_operand:VI_16_32 2)))]
- "TARGET_SSE4_1"
+ "TARGET_SSE2"
{
bool ok = ix86_expand_int_vcond (operands);
gcc_assert (ok);
@@ -2619,7 +2619,7 @@
(match_operand:VI_16_32 5 "register_operand")])
(match_operand:VI_16_32 1)
(match_operand:VI_16_32 2)))]
- "TARGET_SSE4_1"
+ "TARGET_SSE2"
{
bool ok = ix86_expand_int_vcond (operands);
gcc_assert (ok);
@@ -2645,7 +2645,7 @@
(match_operand:VI_16_32 1 "register_operand")
(match_operand:VI_16_32 2 "register_operand")
(match_operand:VI_16_32 3 "register_operand")))]
- "TARGET_SSE4_1"
+ "TARGET_SSE2"
{
ix86_expand_sse_movcc (operands[0], operands[3],
operands[1], operands[2]);
@@ -2752,18 +2752,10 @@
"TARGET_MMX_WITH_SSE"
"operands[2] = force_reg (<MODE>mode, CONSTM1_RTX (<MODE>mode));")
-(define_expand "one_cmpl<mode>2"
- [(set (match_operand:VI_32 0 "register_operand")
- (xor:VI_32
- (match_operand:VI_32 1 "register_operand")
- (match_dup 2)))]
- "TARGET_SSE2"
- "operands[2] = force_reg (<MODE>mode, CONSTM1_RTX (<MODE>mode));")
-
-(define_insn "one_cmplv2qi2"
- [(set (match_operand:V2QI 0 "register_operand" "=r,&x,&v")
- (not:V2QI
- (match_operand:V2QI 1 "register_operand" "0,x,v")))]
+(define_insn "one_cmpl<mode>2"
+ [(set (match_operand:VI_16_32 0 "register_operand" "=?r,&x,&v")
+ (not:VI_16_32
+ (match_operand:VI_16_32 1 "register_operand" "0,x,v")))]
""
"#"
[(set_attr "isa" "*,sse2,avx512vl")
@@ -2771,32 +2763,30 @@
(set_attr "mode" "SI,TI,TI")])
(define_split
- [(set (match_operand:V2QI 0 "general_reg_operand")
- (not:V2QI
- (match_operand:V2QI 1 "general_reg_operand")))]
+ [(set (match_operand:VI_16_32 0 "general_reg_operand")
+ (not:VI_16_32
+ (match_operand:VI_16_32 1 "general_reg_operand")))]
"reload_completed"
[(set (match_dup 0)
(not:SI (match_dup 1)))]
{
- operands[1] = gen_lowpart (SImode, operands[1]);
- operands[0] = gen_lowpart (SImode, operands[0]);
+ operands[1] = lowpart_subreg (SImode, operands[1], <MODE>mode);
+ operands[0] = lowpart_subreg (SImode, operands[0], <MODE>mode);
})
(define_split
- [(set (match_operand:V2QI 0 "sse_reg_operand")
- (not:V2QI
- (match_operand:V2QI 1 "sse_reg_operand")))]
+ [(set (match_operand:VI_16_32 0 "sse_reg_operand")
+ (not:VI_16_32
+ (match_operand:VI_16_32 1 "sse_reg_operand")))]
"TARGET_SSE2 && reload_completed"
- [(set (match_dup 0)
- (xor:V4QI
+ [(set (match_dup 0) (match_dup 2))
+ (set (match_dup 0)
+ (xor:V16QI
(match_dup 0) (match_dup 1)))]
{
- emit_insn
- (gen_rtx_SET (gen_rtx_REG (V16QImode, REGNO (operands[0])),
- CONSTM1_RTX (V16QImode)));
-
- operands[1] = gen_lowpart (V4QImode, operands[1]);
- operands[0] = gen_lowpart (V4QImode, operands[0]);
+ operands[2] = CONSTM1_RTX (V16QImode);
+ operands[1] = lowpart_subreg (V16QImode, operands[1], <MODE>mode);
+ operands[0] = lowpart_subreg (V16QImode, operands[0], <MODE>mode);
})
(define_insn "mmx_andnot<mode>3"
@@ -2816,24 +2806,11 @@
(set_attr "mode" "DI,TI,TI,TI")])
(define_insn "*andnot<mode>3"
- [(set (match_operand:VI_32 0 "register_operand" "=x,x,v")
- (and:VI_32
- (not:VI_32 (match_operand:VI_32 1 "register_operand" "0,x,v"))
- (match_operand:VI_32 2 "register_operand" "x,x,v")))]
- "TARGET_SSE2"
- "@
- pandn\t{%2, %0|%0, %2}
- vpandn\t{%2, %1, %0|%0, %1, %2}
- vpandnd\t{%2, %1, %0|%0, %1, %2}"
- [(set_attr "isa" "noavx,avx,avx512vl")
- (set_attr "type" "sselog")
- (set_attr "mode" "TI")])
-
-(define_insn "*andnotv2qi3"
- [(set (match_operand:V2QI 0 "register_operand" "=&r,r,x,x,v")
- (and:V2QI
- (not:V2QI (match_operand:V2QI 1 "register_operand" "0,r,0,x,v"))
- (match_operand:V2QI 2 "register_operand" "r,r,x,x,v")))
+ [(set (match_operand:VI_16_32 0 "register_operand" "=?&r,?r,x,x,v")
+ (and:VI_16_32
+ (not:VI_16_32
+ (match_operand:VI_16_32 1 "register_operand" "0,r,0,x,v"))
+ (match_operand:VI_16_32 2 "register_operand" "r,r,x,x,v")))
(clobber (reg:CC FLAGS_REG))]
""
"#"
@@ -2842,10 +2819,10 @@
(set_attr "mode" "SI,SI,TI,TI,TI")])
(define_split
- [(set (match_operand:V2QI 0 "general_reg_operand")
- (and:V2QI
- (not:V2QI (match_operand:V2QI 1 "general_reg_operand"))
- (match_operand:V2QI 2 "general_reg_operand")))
+ [(set (match_operand:VI_16_32 0 "general_reg_operand")
+ (and:VI_16_32
+ (not:VI_16_32 (match_operand:VI_16_32 1 "general_reg_operand"))
+ (match_operand:VI_16_32 2 "general_reg_operand")))
(clobber (reg:CC FLAGS_REG))]
"TARGET_BMI && reload_completed"
[(parallel
@@ -2853,16 +2830,16 @@
(and:SI (not:SI (match_dup 1)) (match_dup 2)))
(clobber (reg:CC FLAGS_REG))])]
{
- operands[2] = gen_lowpart (SImode, operands[2]);
- operands[1] = gen_lowpart (SImode, operands[1]);
- operands[0] = gen_lowpart (SImode, operands[0]);
+ operands[2] = lowpart_subreg (SImode, operands[2], <MODE>mode);
+ operands[1] = lowpart_subreg (SImode, operands[1], <MODE>mode);
+ operands[0] = lowpart_subreg (SImode, operands[0], <MODE>mode);
})
(define_split
- [(set (match_operand:V2QI 0 "general_reg_operand")
- (and:V2QI
- (not:V2QI (match_operand:V2QI 1 "general_reg_operand"))
- (match_operand:V2QI 2 "general_reg_operand")))
+ [(set (match_operand:VI_16_32 0 "general_reg_operand")
+ (and:VI_16_32
+ (not:VI_16_32 (match_operand:VI_16_32 1 "general_reg_operand"))
+ (match_operand:VI_16_32 2 "general_reg_operand")))
(clobber (reg:CC FLAGS_REG))]
"!TARGET_BMI && reload_completed"
[(set (match_dup 0)
@@ -2872,24 +2849,24 @@
(and:SI (match_dup 0) (match_dup 2)))
(clobber (reg:CC FLAGS_REG))])]
{
- operands[2] = gen_lowpart (SImode, operands[2]);
- operands[1] = gen_lowpart (SImode, operands[1]);
- operands[0] = gen_lowpart (SImode, operands[0]);
+ operands[2] = lowpart_subreg (SImode, operands[2], <MODE>mode);
+ operands[1] = lowpart_subreg (SImode, operands[1], <MODE>mode);
+ operands[0] = lowpart_subreg (SImode, operands[0], <MODE>mode);
})
(define_split
- [(set (match_operand:V2QI 0 "sse_reg_operand")
- (and:V2QI
- (not:V2QI (match_operand:V2QI 1 "sse_reg_operand"))
- (match_operand:V2QI 2 "sse_reg_operand")))
+ [(set (match_operand:VI_16_32 0 "sse_reg_operand")
+ (and:VI_16_32
+ (not:VI_16_32 (match_operand:VI_16_32 1 "sse_reg_operand"))
+ (match_operand:VI_16_32 2 "sse_reg_operand")))
(clobber (reg:CC FLAGS_REG))]
"TARGET_SSE2 && reload_completed"
[(set (match_dup 0)
- (and:V4QI (not:V4QI (match_dup 1)) (match_dup 2)))]
+ (and:V16QI (not:V16QI (match_dup 1)) (match_dup 2)))]
{
- operands[2] = gen_lowpart (V4QImode, operands[2]);
- operands[1] = gen_lowpart (V4QImode, operands[1]);
- operands[0] = gen_lowpart (V4QImode, operands[0]);
+ operands[2] = lowpart_subreg (V16QImode, operands[2], <MODE>mode);
+ operands[1] = lowpart_subreg (V16QImode, operands[1], <MODE>mode);
+ operands[0] = lowpart_subreg (V16QImode, operands[0], <MODE>mode);
})
(define_expand "mmx_<code><mode>3"
@@ -2925,24 +2902,10 @@
(set_attr "mode" "DI,TI,TI,TI")])
(define_insn "<code><mode>3"
- [(set (match_operand:VI_32 0 "register_operand" "=x,x,v")
- (any_logic:VI_32
- (match_operand:VI_32 1 "register_operand" "%0,x,v")
- (match_operand:VI_32 2 "register_operand" "x,x,v")))]
- "TARGET_SSE2"
- "@
- p<logic>\t{%2, %0|%0, %2}
- vp<logic>\t{%2, %1, %0|%0, %1, %2}
- vp<logic>d\t{%2, %1, %0|%0, %1, %2}"
- [(set_attr "isa" "noavx,avx,avx512vl")
- (set_attr "type" "sselog")
- (set_attr "mode" "TI")])
-
-(define_insn "<code>v2qi3"
- [(set (match_operand:V2QI 0 "register_operand" "=r,x,x,v")
- (any_logic:V2QI
- (match_operand:V2QI 1 "register_operand" "%0,0,x,v")
- (match_operand:V2QI 2 "register_operand" "r,x,x,v")))
+ [(set (match_operand:VI_16_32 0 "register_operand" "=?r,x,x,v")
+ (any_logic:VI_16_32
+ (match_operand:VI_16_32 1 "register_operand" "%0,0,x,v")
+ (match_operand:VI_16_32 2 "register_operand" "r,x,x,v")))
(clobber (reg:CC FLAGS_REG))]
""
"#"
@@ -2951,10 +2914,10 @@
(set_attr "mode" "SI,TI,TI,TI")])
(define_split
- [(set (match_operand:V2QI 0 "general_reg_operand")
- (any_logic:V2QI
- (match_operand:V2QI 1 "general_reg_operand")
- (match_operand:V2QI 2 "general_reg_operand")))
+ [(set (match_operand:VI_16_32 0 "general_reg_operand")
+ (any_logic:VI_16_32
+ (match_operand:VI_16_32 1 "general_reg_operand")
+ (match_operand:VI_16_32 2 "general_reg_operand")))
(clobber (reg:CC FLAGS_REG))]
"reload_completed"
[(parallel
@@ -2962,24 +2925,24 @@
(any_logic:SI (match_dup 1) (match_dup 2)))
(clobber (reg:CC FLAGS_REG))])]
{
- operands[2] = gen_lowpart (SImode, operands[2]);
- operands[1] = gen_lowpart (SImode, operands[1]);
- operands[0] = gen_lowpart (SImode, operands[0]);
+ operands[2] = lowpart_subreg (SImode, operands[2], <MODE>mode);
+ operands[1] = lowpart_subreg (SImode, operands[1], <MODE>mode);
+ operands[0] = lowpart_subreg (SImode, operands[0], <MODE>mode);
})
(define_split
- [(set (match_operand:V2QI 0 "sse_reg_operand")
- (any_logic:V2QI
- (match_operand:V2QI 1 "sse_reg_operand")
- (match_operand:V2QI 2 "sse_reg_operand")))
+ [(set (match_operand:VI_16_32 0 "sse_reg_operand")
+ (any_logic:VI_16_32
+ (match_operand:VI_16_32 1 "sse_reg_operand")
+ (match_operand:VI_16_32 2 "sse_reg_operand")))
(clobber (reg:CC FLAGS_REG))]
"TARGET_SSE2 && reload_completed"
[(set (match_dup 0)
- (any_logic:V4QI (match_dup 1) (match_dup 2)))]
+ (any_logic:V16QI (match_dup 1) (match_dup 2)))]
{
- operands[2] = gen_lowpart (V4QImode, operands[2]);
- operands[1] = gen_lowpart (V4QImode, operands[1]);
- operands[0] = gen_lowpart (V4QImode, operands[0]);
+ operands[2] = lowpart_subreg (V16QImode, operands[2], <MODE>mode);
+ operands[1] = lowpart_subreg (V16QImode, operands[1], <MODE>mode);
+ operands[0] = lowpart_subreg (V16QImode, operands[0], <MODE>mode);
})
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1,6 +1,6 @@
/* PR target/100637 */
/* { dg-do compile } */
-/* { dg-options "-O2 -msse4" } */
+/* { dg-options "-O2 -msse2" } */
typedef unsigned char __attribute__((__vector_size__ (4))) __v4qu;
typedef char __attribute__((__vector_size__ (4))) __v4qi;
@@ -1,6 +1,6 @@
/* PR target/100637 */
/* { dg-do compile } */
-/* { dg-options "-O2 -msse4" } */
+/* { dg-options "-O2 -msse2" } */
typedef unsigned short __attribute__((__vector_size__ (4))) __v2hu;
typedef short __attribute__((__vector_size__ (4))) __v2hi;
@@ -1,6 +1,6 @@
/* PR target/103861 */
/* { dg-do compile } */
-/* { dg-options "-O2 -msse4" } */
+/* { dg-options "-O2 -msse2" } */
typedef unsigned char __attribute__((__vector_size__ (2))) __v2qu;
typedef char __attribute__((__vector_size__ (2))) __v2qi;
@@ -5,17 +5,14 @@
typedef char __v4qi __attribute__ ((__vector_size__ (4)));
__v4qi and (__v4qi a, __v4qi b) { return a & b; };
-/* { dg-final { scan-assembler "andv4qi3" } } */
__v4qi andn (__v4qi a, __v4qi b) { return a & ~b; };
-/* { dg-final { scan-assembler "andnotv4qi3" } } */
__v4qi or (__v4qi a, __v4qi b) { return a | b; };
-/* { dg-final { scan-assembler "iorv4qi3" } } */
__v4qi xor (__v4qi a, __v4qi b) { return a ^ b; };
+
__v4qi not (__v4qi a) { return ~a; };
-/* { dg-final { scan-assembler-times "xorv4qi3" 2 } } */
__v4qi plus (__v4qi a, __v4qi b) { return a + b; };
/* { dg-final { scan-assembler "addv4qi3" } } */
@@ -6,17 +6,14 @@ typedef short __v2hi __attribute__ ((__vector_size__ (4)));
typedef unsigned short __v2hu __attribute__ ((__vector_size__ (4)));
__v2hi and (__v2hi a, __v2hi b) { return a & b; };
-/* { dg-final { scan-assembler "andv2hi3" } } */
__v2hi andn (__v2hi a, __v2hi b) { return a & ~b; };
-/* { dg-final { scan-assembler "andnotv2hi3" } } */
__v2hi or (__v2hi a, __v2hi b) { return a | b; };
-/* { dg-final { scan-assembler "iorv2hi3" } } */
__v2hi xor (__v2hi a, __v2hi b) { return a ^ b; };
+
__v2hi not (__v2hi a) { return ~a; };
-/* { dg-final { scan-assembler-times "xorv2hi3" 2 } } */
__v2hi plus (__v2hi a, __v2hi b) { return a + b; };
/* { dg-final { scan-assembler "addv2hi3" } } */
@@ -1,6 +1,6 @@
/* PR target/100637 */
/* { dg-do compile } */
-/* { dg-options "-O2 -ftree-vectorize -msse4" } */
+/* { dg-options "-O2 -ftree-vectorize -msse2" } */
typedef char T;
@@ -1,6 +1,6 @@
/* PR target/100637 */
/* { dg-do compile } */
-/* { dg-options "-O2 -ftree-vectorize -msse4" } */
+/* { dg-options "-O2 -ftree-vectorize -msse2" } */
typedef char T;
@@ -14,7 +14,7 @@ int main (int argc, char *argv[])
v0 + v1, /* { dg-warning "expanded piecewise" } */
v0 - v1, /* { dg-warning "expanded piecewise" } */
v0 > v1, /* { dg-warning "expanded piecewise" } */
- v0 & v1, /* { dg-warning "expanded piecewise" } */
+ v0 & v1, /* { dg-warning "expanded in parallel" } */
__builtin_shuffle (v0, v1), /* { dg-warning "expanded piecewise" } */
__builtin_shuffle (v0, v1, v1) /* { dg-warning "expanded piecewise" } */
};