From: Bill Schmidt Date: Wed, 15 Jul 2015 16:31:46 +0000 (+0000) Subject: simplify-rtx.c (simplify_ternary_operation): Add simplification for (!c) != {0,.... X-Git-Tag: upstream/12.2.0~53512 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=34222cd6cc4da69d858da0776b5248b3c7b0aa61;p=platform%2Fupstream%2Fgcc.git simplify-rtx.c (simplify_ternary_operation): Add simplification for (!c) != {0,...,0} ? a : b for vector modes. [gcc] 2015-07-15 Bill Schmidt * simplify-rtx.c (simplify_ternary_operation): Add simplification for (!c) != {0,...,0} ? a : b for vector modes. [gcc/testsuite] 2015-07-15 Bill Schmidt * gcc.target/powerpc/vec-cmp-sel.c: New test. From-SVN: r225840 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a2ce483..babf07f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-07-15 Bill Schmidt + + * simplify-rtx.c (simplify_ternary_operation): Add simplification + for (!c) != {0,...,0} ? a : b for vector modes. + 2015-07-15 Paolo Bonzini Martin Jambor diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 91e4b9c..fde9944 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -5247,6 +5247,32 @@ simplify_ternary_operation (enum rtx_code code, machine_mode mode, && rtx_equal_p (XEXP (op0, 1), op1)))) return op2; + /* Convert (!c) != {0,...,0} ? a : b into + c != {0,...,0} ? b : a for vector modes. */ + if (VECTOR_MODE_P (GET_MODE (op1)) + && GET_CODE (op0) == NE + && GET_CODE (XEXP (op0, 0)) == NOT + && GET_CODE (XEXP (op0, 1)) == CONST_VECTOR) + { + rtx cv = XEXP (op0, 1); + int nunits = CONST_VECTOR_NUNITS (cv); + bool ok = true; + for (int i = 0; i < nunits; ++i) + if (CONST_VECTOR_ELT (cv, i) != const0_rtx) + { + ok = false; + break; + } + if (ok) + { + rtx new_op0 = gen_rtx_NE (GET_MODE (op0), + XEXP (XEXP (op0, 0), 0), + XEXP (op0, 1)); + rtx retval = gen_rtx_IF_THEN_ELSE (mode, new_op0, op2, op1); + return retval; + } + } + if (COMPARISON_P (op0) && ! side_effects_p (op0)) { machine_mode cmp_mode = (GET_MODE (XEXP (op0, 0)) == VOIDmode diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f8ff300..84ee717 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-07-15 Bill Schmidt + + * gcc.target/powerpc/vec-cmp-sel.c: New test. + 2015-07-15 Richard Biener * lib/objc-torture.exp (OBJC_TORTURE_OPTIONS): Remove diff --git a/gcc/testsuite/gcc.target/powerpc/vec-cmp-sel.c b/gcc/testsuite/gcc.target/powerpc/vec-cmp-sel.c new file mode 100644 index 0000000..2888216 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vec-cmp-sel.c @@ -0,0 +1,20 @@ +/* { dg-do compile { target powerpc64*-*-* } } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-options "-maltivec -O2" } */ +/* { dg-final { scan-assembler "vcmpgtsd" } } */ +/* { dg-final { scan-assembler-not "xxlnor" } } */ + +/* Test code in simplify-rtx.c that converts + (!c) != {0,...,0} ? a : b + into + c != {0,...,0} ? b : a */ + +#include + +vector signed long long foo () { + vector signed long long x = { 25399, -12900 }; + vector signed long long y = { 12178, -9987 }; + vector bool long long b = vec_cmpge (x, y); + vector signed long long z = vec_sel (y, x, b); + return z; +}