This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH] Fix PR 31531: A microoptimization of isnegative of signed integer
- From: "Hurugalawadi, Naveen" <Naveen dot Hurugalawadi at caviumnetworks dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Senthil Kumar Selvaraj <senthil_kumar dot selvaraj at atmel dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "Pinski, Andrew" <Andrew dot Pinski at caviumnetworks dot com>
- Date: Thu, 14 Apr 2016 03:11:49 +0000
- Subject: Re: PATCH] Fix PR 31531: A microoptimization of isnegative of signed integer
- Authentication-results: sourceware.org; auth=none
- Authentication-results: atmel.com; dkim=none (message not signed) header.d=none;atmel.com; dmarc=none action=none header.from=caviumnetworks.com;
- References: <SN2PR0701MB1024F7BEE5230333B12BAA888ED50 at SN2PR0701MB1024 dot namprd07 dot prod dot outlook dot com> <87egcn7eae dot fsf at atmel dot com> <CAFiYyc2+VUFRvf-ipkhh0eQPPhqeBLvhY=VmtVtAN70V2-kC3g at mail dot gmail dot com> <SN2PR0701MB1024F4E510034BC0F61FC0348EAD0 at SN2PR0701MB1024 dot namprd07 dot prod dot outlook dot com>,<CAFiYyc07-gFk9358Vg8EwPLN+BwiYKtS-GR9ztgRjdANyWT8BA at mail dot gmail dot com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:23
Hi Richard,
>> What's the motivation of splitting this into a equal type
>> and a non-equal type case? Simply only allow nop-conversions here
>> (tree_nop_conversion_p) and unconditionally emit
Done.
Thanks for the review and Comments. Implemented the modifications
as per you review comments.
Please review the modified patch and let me know if its okay?
Thanks,
Naveen
diff --git a/gcc/match.pd b/gcc/match.pd
index 75aa601..928a529 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -1896,10 +1896,13 @@ 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_CODE (@1) == VECTOR_CST)
+ && (TYPE_PRECISION (TREE_TYPE (@3)) == TYPE_PRECISION (TREE_TYPE (@2)))
+ && tree_nop_conversion_p (type, TREE_TYPE (@0)))
+ (with { tree newtype = TREE_TYPE (@1); }
+ (scmp (view_convert:newtype @0) (bit_not @1))))))
(for cmp (simple_comparison)
/* Fold (double)float1 CMP (double)float2 into float1 CMP float2. */