From 5bfba2b58ddb37c89e0633a2dc48fa8c4430a026 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 14 Nov 2018 13:36:59 +0100 Subject: [PATCH] re PR rtl-optimization/87817 (gcc.target/i386/bmi2-bzhi-2.c execution test) PR rtl-optimization/87817 * config/i386/i386.c (ix86_fold_builtin): For _bzhi_u{32,64} if last argument has low 8 bits clear, fold to 0. * gcc.target/i386/bmi2-bzhi-3.c (main): Add a couple of new tests. From-SVN: r266140 --- gcc/ChangeLog | 6 ++++++ gcc/config/i386/i386.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/bmi2-bzhi-3.c | 12 ++++++++++-- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d77ae3666db..6f9b26e465c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-11-14 Jakub Jelinek + + PR rtl-optimization/87817 + * config/i386/i386.c (ix86_fold_builtin): For _bzhi_u{32,64} if + last argument has low 8 bits clear, fold to 0. + 2018-11-14 Iain Sandoe * tree-vect-data-refs.c (vect_can_force_dr_alignment_p): Cast diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index b3e0807b894..76a92b167f5 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -32671,6 +32671,8 @@ ix86_fold_builtin (tree fndecl, int n_args, unsigned int idx = tree_to_uhwi (args[1]) & 0xff; if (idx >= TYPE_PRECISION (TREE_TYPE (args[0]))) return args[0]; + if (idx == 0) + return build_int_cst (TREE_TYPE (TREE_TYPE (fndecl)), 0); if (!tree_fits_uhwi_p (args[0])) break; unsigned HOST_WIDE_INT res = tree_to_uhwi (args[0]); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 303bca4bd53..d8897fa5dbe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-11-14 Jakub Jelinek + + PR rtl-optimization/87817 + * gcc.target/i386/bmi2-bzhi-3.c (main): Add a couple of new tests. + 2018-11-14 Wilco Dijkstra * gcc.target/aarch64/pr62178.c: Relax scan-assembler checks. diff --git a/gcc/testsuite/gcc.target/i386/bmi2-bzhi-3.c b/gcc/testsuite/gcc.target/i386/bmi2-bzhi-3.c index cc334eba1ba..79905eba9b5 100644 --- a/gcc/testsuite/gcc.target/i386/bmi2-bzhi-3.c +++ b/gcc/testsuite/gcc.target/i386/bmi2-bzhi-3.c @@ -58,7 +58,11 @@ main () link_error (); if (_bzhi_u32 (c, 32) != c || _bzhi_u32 (c, 64) != c - || _bzhi_u32 (c, 255) != c) + || _bzhi_u32 (c, 255) != c + || _bzhi_u32 (c, 544) != c + || _bzhi_u32 (c, 0) != 0 + || _bzhi_u32 (c, 256) != 0 + || _bzhi_u32 (c, 1024) != 0) link_error (); #ifdef __x86_64__ if (f21 () != 0 || f22 (-1ULL) != 0 @@ -70,7 +74,11 @@ main () || f33 () != -1ULL || f34 (-1ULL) != -1ULL) link_error (); if (_bzhi_u64 (d, 64) != d - || _bzhi_u64 (d, 255) != d) + || _bzhi_u64 (d, 255) != d + || _bzhi_u64 (d, 576) != d + || _bzhi_u64 (d, 0) != 0 + || _bzhi_u64 (d, 256) != 0 + || _bzhi_u64 (d, 512) != 0) link_error (); #endif return 0; -- 2.30.2