diff options
author | Bill Schmidt <wschmidt@linux.vnet.ibm.com> | 2015-07-15 16:31:46 +0000 |
---|---|---|
committer | William Schmidt <wschmidt@gcc.gnu.org> | 2015-07-15 16:31:46 +0000 |
commit | 34222cd6cc4da69d858da0776b5248b3c7b0aa61 (patch) | |
tree | 04c76af59269f7a1c5e9de6f9dc08394b7276f58 /gcc/simplify-rtx.c | |
parent | ff302741f10c7d6f014eb46f7632b57bdc43a4f5 (diff) | |
download | gcc-34222cd6cc4da69d858da0776b5248b3c7b0aa61.zip gcc-34222cd6cc4da69d858da0776b5248b3c7b0aa61.tar.gz gcc-34222cd6cc4da69d858da0776b5248b3c7b0aa61.tar.bz2 |
simplify-rtx.c (simplify_ternary_operation): Add simplification for (!c) != {0,...,0} ? a : b for vector modes.
[gcc]
2015-07-15 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
* simplify-rtx.c (simplify_ternary_operation): Add simplification
for (!c) != {0,...,0} ? a : b for vector modes.
[gcc/testsuite]
2015-07-15 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
* gcc.target/powerpc/vec-cmp-sel.c: New test.
From-SVN: r225840
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r-- | gcc/simplify-rtx.c | 26 |
1 files changed, 26 insertions, 0 deletions
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 |