Bug 67421 - gcc.dg/wide-shift-64.c FAILs
Summary: gcc.dg/wide-shift-64.c FAILs
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: 6.0
Assignee: Jiong Wang
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-01 12:43 UTC by Rainer Orth
Modified: 2015-09-10 10:44 UTC (History)
0 users

See Also:
Host: sparc*-sun-solaris2.*
Target: sparc*-sun-solaris2.*
Build: sparc*-sun-solaris2.*
Known to work:
Known to fail:
Last reconfirmed:


Attachments
wide-shift-64.c.219r.combine (1.25 KB, text/plain)
2015-09-01 12:43 UTC, Rainer Orth
Details
wide-shift-64.c.219r.combine (1.42 KB, text/plain)
2015-09-03 09:17 UTC, Rainer Orth
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Orth 2015-09-01 12:43:43 UTC
Created attachment 36275 [details]
wide-shift-64.c.219r.combine

The new gcc.dg/wide-shift-64.c testcase FAILs on SPARC for the 64-bit multilib
only:

FAIL: gcc.dg/wide-shift-64.c scan-rtl-dump-not combine "ior"

I'm attaching the dump.

Btw. I noticed a nit: both the ChangeLog entry and the commit message mention gcc.dg/wide_shift_64_1.c and gcc.dg/wide_shift_128_1.c,
  while the actual files are named gcc.dg/wide-shift-64.c and gcc.dg/wide-shift-128.c (similarly for the aarch64 testcase), which makes it harder to find
when/by whom the files were committed.

  Rainer
Comment 1 Jiong Wang 2015-09-02 10:27:51 UTC
(In reply to Rainer Orth from comment #0)
> Created attachment 36275 [details]
> wide-shift-64.c.219r.combine
> 
> The new gcc.dg/wide-shift-64.c testcase FAILs on SPARC for the 64-bit
> multilib
> only:
> 
> FAIL: gcc.dg/wide-shift-64.c scan-rtl-dump-not combine "ior"
> 
> I'm attaching the dump.

Rainer,

  I am trying to reproduce this on my cross environment while I can't.
 
  And searching in your dump file, I haven't found "ior" so the testcase should have passed. 

  Can you please have a quick looks at the compile options used when testing this testcase in your multi-lib environment, then I can reproduce in my local sparc x86 cross env where I only have cc1 configured with --target=sparc-linux.
  
  Thanks.
Comment 2 ro@CeBiTec.Uni-Bielefeld.DE 2015-09-03 09:16:44 UTC
> --- Comment #1 from Jiong Wang <jiwang at gcc dot gnu.org> ---
> (In reply to Rainer Orth from comment #0)
>> Created attachment 36275 [details]
>> wide-shift-64.c.219r.combine
>> 
>> The new gcc.dg/wide-shift-64.c testcase FAILs on SPARC for the 64-bit
>> multilib
>> only:
>> 
>> FAIL: gcc.dg/wide-shift-64.c scan-rtl-dump-not combine "ior"
>> 
>> I'm attaching the dump.
>
> Rainer,
>
>   I am trying to reproduce this on my cross environment while I can't.
>
>   And searching in your dump file, I haven't found "ior" so the testcase should
> have passed. 

I just noticed I must have been dreaming when submitting this bug
report: it's the *32-bit* case that fails, not the 64-bit one.  I'm
attaching the correct dump this time.

>   Can you please have a quick looks at the compile options used when testing
> this testcase in your multi-lib environment, then I can reproduce in my local
> sparc x86 cross env where I only have cc1 configured with --target=sparc-linux.

cc1 is invoked like this for a 32-bit-default configuration:

$ cc1 -quiet wide-shift-64.c -mcpu=v9 -O2 -fdump-rtl-combine -o wide-shift-64.s

	Rainer
Comment 3 Rainer Orth 2015-09-03 09:17:09 UTC
Created attachment 36290 [details]
wide-shift-64.c.219r.combine

32-bit dump
Comment 4 Jiong Wang 2015-09-03 10:31:18 UTC
(In reply to ro@CeBiTec.Uni-Bielefeld.DE from comment #2)
> cc1 is invoked like this for a 32-bit-default configuration:
> 
> $ cc1 -quiet wide-shift-64.c -mcpu=v9 -O2 -fdump-rtl-combine -o
> wide-shift-64.s
> 
> 	Rainer

Thanks, I basically understand where is the problem. By some option combination sparc will enable target private wide shift pattern to override the middle-end generic optimization, as the generic optimization honor target private mechanism by the follow checking at expr.c:

             && ! have_insn_for (ASHIFT, mode)  

although the target private wide shift generate worse code.

I can't reproduce this issue by the following configure on trunk

../gcc-git-official/configure --enable-tls --target=sparc-linux --enable-languages=c,c++

While after search sparc source code, I found sparc defined target private wide shift, but it's only enabled when "TARGET_ARCH64 || TARGET_V8PLUS", then only used when "! TARGET_ARCH64"

(define_expand "ashldi3"
  "TARGET_ARCH64 || TARGET_V8PLUS"
{
  if (! TARGET_ARCH64)

So, the testcase failed when I pass -mv8plus and -mcpu=v9 at the same time which enable sparc target wide shift under 32bit.

[FAIL]./cc1 -quiet wide-shift-64.c -O2 -fdump-rtl-combine -nostdinc -mv8plus -mcpu=v9

Jeff was suggesting we add cost check in generic code to make better decision whether generic code should honor target private pattern.

Currently, I think we can just skip sparc for this testcase as I haven't found good way in dejagnu to just skip when "-mv8plus" specified.
Comment 5 Jiong Wang 2015-09-10 10:37:48 UTC
Author: jiwang
Date: Thu Sep 10 10:37:17 2015
New Revision: 227629

URL: https://gcc.gnu.org/viewcvs?rev=227629&root=gcc&view=rev
Log:
[Patch/expand] Cost instruction sequences when doing left wide shift

Patch background details:

    https://gcc.gnu.org/ml/gcc-patches/2015-08/msg01147.html

gcc/
  PR rtl-optimization/67421
  * expr.c (expand_expr_real_2): Cost instrcution sequences when doing left wide
  shift tranformation.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/expr.c
Comment 6 Jiong Wang 2015-09-10 10:44:36 UTC
fixed