Message ID | SN2PR0701MB1024F4E510034BC0F61FC0348EAD0@SN2PR0701MB1024.namprd07.prod.outlook.com |
---|---|
State | New |
Headers | show |
Hi, Please find attached the patch that enhances the existing pattern. Please review the patch at the following link and let me know if there should be any modifications in it:- https://gcc.gnu.org/ml/gcc-patches/2016-02/msg01035.html Thanks, Naveen
Hi, Please find attached the patch that enhances the existing pattern. Please review the patch at the following link and let me know if there should be any modifications in it:- https://gcc.gnu.org/ml/gcc-patches/2016-02/msg01035.html Thanks, Naveen
Hi, Please review the patch at the following link and let me know if there should be any modifications in it:- https://gcc.gnu.org/ml/gcc-patches/2016-02/msg01035.html Thanks, Naveen
On Tue, Feb 16, 2016 at 5:50 AM, Hurugalawadi, Naveen <Naveen.Hurugalawadi@caviumnetworks.com> wrote: > Hi, > >>> I'm also failing to see why you can't enhance the existing > > Please find attached the patch that enhances the existing pattern. > Please review the patch and let me know if any further modifications > are required. What's the motivation of splitting this into a equal type (borken for the vector case) and a non-equal type case? Simply only allow nop-conversions here (tree_nop_conversion_p) and unconditionally emit (scmp (view_convert:newtype @0) (bit_not @1)) ? The conversion will be omitted if it turns out to be not necessary and a view_convert will be turned into a regular conversion for non-vector cases. Richard. > Thanks, > Naveen
diff --git a/gcc/match.pd b/gcc/match.pd index 6c8ebd5..bd47a91 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1871,10 +1871,21 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (for cmp (simple_comparison) scmp (swapped_simple_comparison) (simplify - (cmp (bit_not@2 @0) CONSTANT_CLASS_P@1) + (cmp (convert?@3 (bit_not@2 @0)) CONSTANT_CLASS_P@1) (if (single_use (@2) - && (TREE_CODE (@1) == INTEGER_CST || TREE_CODE (@1) == VECTOR_CST)) - (scmp @0 (bit_not @1))))) + && ((TREE_CODE (@1) == INTEGER_CST && TREE_TYPE (@3) == TREE_TYPE (@2)) + || (TREE_CODE (@1) == VECTOR_CST + && (VECTOR_TYPE_P (TREE_TYPE (@3)) + == VECTOR_TYPE_P (TREE_TYPE (@2))) + && (TYPE_VECTOR_SUBPARTS (TREE_TYPE (@3)) + == TYPE_VECTOR_SUBPARTS (TREE_TYPE (@2))) + && (TYPE_MODE (TREE_TYPE (TREE_TYPE (@3))) + == TYPE_MODE (TREE_TYPE (TREE_TYPE (@2))))))) + (scmp @0 (bit_not @1)) + (if (TYPE_PRECISION (TREE_TYPE (@3)) == TYPE_PRECISION (TREE_TYPE (@2)) + && (TREE_CODE (@1) == INTEGER_CST)) + (with { tree newtype = TREE_TYPE (@1); } + (scmp (convert:newtype @0) (bit_not @1))))))) (for cmp (simple_comparison) /* Fold (double)float1 CMP (double)float2 into float1 CMP float2. */ diff --git a/gcc/testsuite/gcc.dg/pr31531.c b/gcc/testsuite/gcc.dg/pr31531.c new file mode 100644 index 0000000..cf9dd82 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr31531.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ +/* { dg-require-effective-target int32 } */ + +int isnegative_optimized_4 (unsigned int X) +{ + int result; + if ((~X) >> 31) + result = 0; + else + result = 1; + return result; +} + +/* { dg-final { scan-tree-dump-times "signed int X.0" 1 "gimple" } } */
Hi, >> I'm also failing to see why you can't enhance the existing Please find attached the patch that enhances the existing pattern. Please review the patch and let me know if any further modifications are required. Thanks, Naveen