diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index 9c92b07d5cd84c64611eb66aa0ee0136ea526085..acf9e00d4906b7d6de22ee8d4d517d2f224922b2 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -4540,7 +4540,8 @@ ix86_expand_int_sse_cmp (rtx dest, enum rtx_code code, rtx cop0, rtx cop1, rtvec v = rtvec_alloc (n_elts); for (i = 0; i < n_elts; ++i) RTVEC_ELT (v, i) - = GEN_INT (INTVAL (CONST_VECTOR_ELT (cop1, i)) + 1); + = gen_int_mode (INTVAL (CONST_VECTOR_ELT (cop1, i)) + 1, + eltmode); cop1 = gen_rtx_CONST_VECTOR (mode, v); std::swap (cop0, cop1); code = code == LE ? GT : GTU; @@ -4584,7 +4585,8 @@ ix86_expand_int_sse_cmp (rtx dest, enum rtx_code code, rtx cop0, rtx cop1, rtvec v = rtvec_alloc (n_elts); for (i = 0; i < n_elts; ++i) RTVEC_ELT (v, i) - = GEN_INT (INTVAL (CONST_VECTOR_ELT (cop1, i)) - 1); + = gen_int_mode (INTVAL (CONST_VECTOR_ELT (cop1, i)) - 1, + eltmode); cop1 = gen_rtx_CONST_VECTOR (mode, v); code = code == GE ? GT : GTU; break; diff --git a/gcc/testsuite/gcc.dg/pr107585.c b/gcc/testsuite/gcc.dg/pr107585.c new file mode 100644 index 0000000000000000000000000000000000000000..820e04b6537c712e96b6f3f28dd19acda53dec63 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr107585.c @@ -0,0 +1,13 @@ +/* PR target/107585 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef unsigned char __attribute__((__vector_size__ (16))) V; +char c; +void bar (int); + +void +foo (void) +{ + bar (((V) (c <= (V){127}))[2]); +}