[RFC] ipa bitwise constant propagation

Christophe Lyon christophe.lyon@linaro.org
Mon Aug 29 10:53:00 GMT 2016


On 26 August 2016 at 19:22, Prathamesh Kulkarni
<prathamesh.kulkarni@linaro.org> wrote:
> On 26 August 2016 at 21:53, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>> Hi Prathamesh,
>>
>>> The attached version passes bootstrap+test on
>>> x86_64-unknown-linux-gnu, ppc64le-linux-gnu,
>>> and with c,c++,fortran on armv8l-linux-gnueabihf.
>>> Cross-tested on arm*-*-* and aarch64*-*-*.
>>> Verified the patch survives lto-bootstrap on x86_64-unknown-linux-gnu.
>>> Ok to commit ?
>> [...]
>>> testsuite/
>>>       * gcc.dg/ipa/propbits-1.c: New test-case.
>>>       * gcc.dg/ipa/propbits-2.c: Likewise.
>>>       * gcc.dg/ipa/propbits-3.c: Likewise.
>> [...]
>>> diff --git a/gcc/testsuite/gcc.dg/ipa/propbits-2.c b/gcc/testsuite/gcc.dg/ipa/propbits-2.c
>>> new file mode 100644
>>> index 0000000..3a960f0
>>> --- /dev/null
>>> +++ b/gcc/testsuite/gcc.dg/ipa/propbits-2.c
>>> @@ -0,0 +1,41 @@
>>> +/* x's mask should be meet(0xc, 0x3) == 0xf  */
>>> +
>>> +/* { dg-do compile } */
>>> +/* { dg-options "-O2 -fno-early-inlining -fdump-ipa-cp" } */
>>> +
>>> +extern int pass_test ();
>>> +extern int fail_test ();
>>> +
>>> +__attribute__((noinline))
>>> +static int f1(int x)
>>> +{
>>> +  if ((x & ~0xf) == 0)
>>> +    return pass_test ();
>>> +  else
>>> +    return fail_test ();
>>> +}
>>> +
>>> +__attribute__((noinline))
>>> +static int f2(int y)
>>> +{
>>> +  return f1(y & 0x03);
>>> +}
>>> +
>>> +__attribute__((noinline))
>>> +static int f3(int z)
>>> +{
>>> +  return f1(z & 0xc);
>>> +}
>>> +
>>> +extern int a;
>>> +extern int b;
>>> +
>>> +int main(void)
>>> +{
>>> +  int k = f2(a);
>>> +  int l = f3(b);
>>> +  return k + l;
>>> +}
>>> +
>>> +/* { dg-final { scan-ipa-dump "Adjusting mask for param 0 to 0xf" "cp" } } */
>>> +/* { dg-final { scan-dump-tree-not "fail_test" "optimized" } } */
>>
>> This testcase thoroughly broke make check-gcc:
> Oops, sorry for the breakage. I am not sure how this missed my testing :/
> I obtained test results using test_summary script with and without patch,
> and compared the results with compare_tests which apparently showed no
> regressions...
> Thanks for the fix.
>

Hmmm that's weird indeed.

> Thanks,
> Prathamesh
>>
>> At first, runtest errors out with
>>
>> ERROR: (DejaGnu) proc "scan-dump-tree-not fail_test optimized" does not exist.

I do see this message in gcc.log (and in gcc.sum), but...
>>
>> The resulting incomplete gcc.sum files confuse dg-extract-results.py
>>
>> testsuite/gcc6/gcc.sum.sep: no recognised summary line
>> testsuite/gcc6/gcc.log.sep: no recognised summary line
>>
.... I do not see this...

>> and cause it to emit en empty gcc.sum, effectively losing all gcc
>> testresults in mail-report.log.
and gcc.sum looks quite good (except for the ERROR: message
which is not noticed by the comparison tools).

It could be an effect of a different 'make -j' value, resulting
in different split of gcc.sum.sep, thus making the error
un-noticed.

Christophe

>> This cannot have been tested in any reasonable way.
>>
>> Once you fix the typo (scan-dump-tree-not -> scan-tree-dump-not), at
>> least we get a complete gcc.sum again, but the testcase still shows up as
>>
>> UNRESOLVED: gcc.dg/ipa/propbits-2.c scan-tree-dump-not optimized "fail_test"
>>
>> and gcc.log shows
>>
>> gcc.dg/ipa/propbits-2.c: dump file does not exist
>>
>> Adding -fdump-tree-optimized creates the necessary dump and finally lets
>> the test pass.
>>
>> Here's the resulting patch.  Unless there are objections, I plan to
>> commit it soon.
>>
>>         Rainer
>>
>>
>> 2016-08-26  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>>
>>         * gcc.dg/ipa/propbits-2.c: Add -fdump-tree-optimized to dg-options.
>>         Fix typo.
>>
>>
>>
>> --
>> -----------------------------------------------------------------------------
>> Rainer Orth, Center for Biotechnology, Bielefeld University
>>



More information about the Gcc-patches mailing list