public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/16797] New: PowerPC - Opportunity to remove unnecessary load instructions
@ 2004-07-28 17:00 gcc-bugzilla at gcc dot gnu dot org
  2004-07-28 17:36 ` [Bug target/16797] " bangerth at dealii dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2004-07-28 17:00 UTC (permalink / raw)
  To: gcc-bugs

Description:
A non-optimal code sequence is illustraded.  Values are being loaded from storage unecessarily.   Duplicate using gcc 3.5 and command line:

gcc -O3 -m64 -c test.c

Testcase:
long int i, j;
int foo ()
{

  j = (i>>52);

  if (j< 0) {
    i = 10;
  } else {
    i = 20;
  };

  return i;

}

Assembly:
.foo:
	ld 11,.LC0@toc(2)
	ld 9,.LC1@toc(2)
	ld 0,0(11)
	sradi 0,0,52
	cmpdi 7,0,0
	std 0,0(9)
	blt- 7,.L7
	li 0,20     <-- Load directly into register 3 here...
	std 0,0(11)
	lwa 3,4(11) <-- ... and eliminate this load.
	blr
.L7:
	li 0,10     <-- Load directly into register 3 here...
	std 0,0(11)
	lwa 3,4(11) <-- ... and eliminate this load.
	blr



-- 
           Summary: PowerPC - Opportunity to remove unnecessary load
                    instructions
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P1
         Component: other
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: steinmtz at us dot ibm dot com
                CC: gcc-bugs at gcc dot gnu dot org,steinmtz at us dot ibm
                    dot com
 GCC build triplet: powerpc64-linux
  GCC host triplet: powerpc64-linux
GCC target triplet: powerpc64-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16797


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/16797] PowerPC - Opportunity to remove unnecessary load instructions
  2004-07-28 17:00 [Bug other/16797] New: PowerPC - Opportunity to remove unnecessary load instructions gcc-bugzilla at gcc dot gnu dot org
@ 2004-07-28 17:36 ` bangerth at dealii dot org
  2004-07-28 18:36 ` [Bug tree-optimization/16797] " pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2004-07-28 17:36 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|other                       |target


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16797


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug tree-optimization/16797] Opportunity to remove unnecessary load instructions
  2004-07-28 17:00 [Bug other/16797] New: PowerPC - Opportunity to remove unnecessary load instructions gcc-bugzilla at gcc dot gnu dot org
  2004-07-28 17:36 ` [Bug target/16797] " bangerth at dealii dot org
@ 2004-07-28 18:36 ` pinskia at gcc dot gnu dot org
  2004-07-30 18:11 ` steven at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-28 18:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-28 18:36 -------
Confirmed.  This is not PPC specific at all.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|target                      |tree-optimization
     Ever Confirmed|                            |1
           Keywords|                            |missed-optimization
   Last reconfirmed|0000-00-00 00:00:00         |2004-07-28 18:36:13
               date|                            |
            Summary|PowerPC - Opportunity to    |Opportunity to remove
                   |remove unnecessary load     |unnecessary load
                   |instructions                |instructions


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16797


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug tree-optimization/16797] Opportunity to remove unnecessary load instructions
  2004-07-28 17:00 [Bug other/16797] New: PowerPC - Opportunity to remove unnecessary load instructions gcc-bugzilla at gcc dot gnu dot org
  2004-07-28 17:36 ` [Bug target/16797] " bangerth at dealii dot org
  2004-07-28 18:36 ` [Bug tree-optimization/16797] " pinskia at gcc dot gnu dot org
@ 2004-07-30 18:11 ` steven at gcc dot gnu dot org
  2004-11-03 14:40 ` nathan at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: steven at gcc dot gnu dot org @ 2004-07-30 18:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2004-07-30 18:11 -------
Interestingly, on AMD64 this test case doesn't even need a branch: 
 
foo: 
        movq    i(%rip), %rax		# %rax <-- i 
        sarq    $52, %rax		# %rax <-- (%rax >> 52) 
        movq    %rax, j(%rip)		# j <-- %rax 
        sarq    $11, %rax		# %rax <-- (%rax >> 11) 
        andq    $-10, %rax		# %rax <-- (%rax & -10) 
        addq    $20, %rax		# %rax <-- (%rax + 20) 
        movq    %rax, i(%rip)		# i <-- %rax 
        ret				# return %eax 
 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16797


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug tree-optimization/16797] Opportunity to remove unnecessary load instructions
  2004-07-28 17:00 [Bug other/16797] New: PowerPC - Opportunity to remove unnecessary load instructions gcc-bugzilla at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-07-30 18:11 ` steven at gcc dot gnu dot org
@ 2004-11-03 14:40 ` nathan at gcc dot gnu dot org
  2004-11-08 14:07 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: nathan at gcc dot gnu dot org @ 2004-11-03 14:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From nathan at gcc dot gnu dot org  2004-11-03 14:40 -------
ug. This bug falls between a number of stools.
1) on ppc-64 ints are returned correctly sign extended to 64 bits
2) the tree-ssa optimizers are blind to parameter marshalling, so the necessary
sign extension is added at the tree->rtl conversion
3) When combine runs, there is still one common exit block containing
      i_64 = contents_of_i
      i_32 = (int)i_64
      result = sign_extend (i_32)
As the 'contents_of_i' are initialized in different blocks, combine has no
knowledge of its possible values.  So, it doesn't know the truncation and
extension is a nop.
4) The terminating bb gets duplicated by bbro right at the end of optimization.
No subsequent cse stage runs after that.

If tree-ssa was made ABI aware, we'd be in much better shape.
This is similar to 16802 but with bb-cloning to further expose the stupidity

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16797


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug tree-optimization/16797] Opportunity to remove unnecessary load instructions
  2004-07-28 17:00 [Bug other/16797] New: PowerPC - Opportunity to remove unnecessary load instructions gcc-bugzilla at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-11-03 14:40 ` nathan at gcc dot gnu dot org
@ 2004-11-08 14:07 ` pinskia at gcc dot gnu dot org
  2004-11-08 14:16 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-08 14:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-08 14:07 -------
What really should happening is that we do a combine after we copy the BB for returning (this will help 
more than just this case).

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16797


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug tree-optimization/16797] Opportunity to remove unnecessary load instructions
  2004-07-28 17:00 [Bug other/16797] New: PowerPC - Opportunity to remove unnecessary load instructions gcc-bugzilla at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2004-11-08 14:07 ` pinskia at gcc dot gnu dot org
@ 2004-11-08 14:16 ` pinskia at gcc dot gnu dot org
  2005-06-02 18:47 ` dnovillo at gcc dot gnu dot org
  2005-09-10 17:59 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-08 14:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-08 14:15 -------
Here is a PPC32 example:
short b,d;

short logic_func1() {
  if (d< b) return b; else return d;
}

We get:
        lis r2,ha16(_b)
        lis r9,ha16(_d)
        lha r0,lo16(_b)(r2)
        lha r2,lo16(_d)(r9)
        cmpw cr7,r2,r0
        blt- cr7,L4
        mr r0,r2
L4:
        mr r3,r0  <-- extra
        blr


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16797


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug tree-optimization/16797] Opportunity to remove unnecessary load instructions
  2004-07-28 17:00 [Bug other/16797] New: PowerPC - Opportunity to remove unnecessary load instructions gcc-bugzilla at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2004-11-08 14:16 ` pinskia at gcc dot gnu dot org
@ 2005-06-02 18:47 ` dnovillo at gcc dot gnu dot org
  2005-09-10 17:59 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 12+ messages in thread
From: dnovillo at gcc dot gnu dot org @ 2005-06-02 18:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dnovillo at gcc dot gnu dot org  2005-06-02 18:47 -------

This is not related to range propagation.  Removing dependency on 18373.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|18373                       |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16797


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug tree-optimization/16797] Opportunity to remove unnecessary load instructions
  2004-07-28 17:00 [Bug other/16797] New: PowerPC - Opportunity to remove unnecessary load instructions gcc-bugzilla at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2005-06-02 18:47 ` dnovillo at gcc dot gnu dot org
@ 2005-09-10 17:59 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-10 17:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-10 17:59 -------
Another testcase which effects all targets:
int logic_func1(int b, int d) {
  if (d< b) return b+3; else return d+3;
}

int logic_func2(int b, int d)
{
  int a;
  if (d< b) a = b; else a = d;
  return a+3;
}

Basicially if we move the +3 to the common code, this would be better  (note in the orginal testcase it is 
a cast).

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16797


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug tree-optimization/16797] Opportunity to remove unnecessary load instructions
       [not found] <bug-16797-4@http.gcc.gnu.org/bugzilla/>
@ 2014-12-15 19:17 ` spop at gcc dot gnu.org
  0 siblings, 0 replies; 12+ messages in thread
From: spop at gcc dot gnu.org @ 2014-12-15 19:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16797

Sebastian Pop <spop at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |spop at gcc dot gnu.org
         Resolution|---                         |DUPLICATE

--- Comment #10 from Sebastian Pop <spop at gcc dot gnu.org> ---
Fixed in http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137631

*** This bug has been marked as a duplicate of bug 23455 ***


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug tree-optimization/16797] Opportunity to remove unnecessary load instructions
       [not found] <bug-16797-8614@http.gcc.gnu.org/bugzilla/>
  2005-11-02 17:16 ` pinskia at gcc dot gnu dot org
@ 2006-08-26  4:37 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-26  4:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pinskia at gcc dot gnu dot org  2006-08-26 04:37 -------
The load issue is really the same as PR 25553 and this is target independent.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|powerpc64-linux             |
   GCC host triplet|powerpc64-linux             |
 GCC target triplet|powerpc64-linux             |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16797


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug tree-optimization/16797] Opportunity to remove unnecessary load instructions
       [not found] <bug-16797-8614@http.gcc.gnu.org/bugzilla/>
@ 2005-11-02 17:16 ` pinskia at gcc dot gnu dot org
  2006-08-26  4:37 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-02 17:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2005-11-02 17:16 -------
All P1 enhancements not targeted towards 4.1, moving to P5.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P5


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16797


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-12-15 19:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-28 17:00 [Bug other/16797] New: PowerPC - Opportunity to remove unnecessary load instructions gcc-bugzilla at gcc dot gnu dot org
2004-07-28 17:36 ` [Bug target/16797] " bangerth at dealii dot org
2004-07-28 18:36 ` [Bug tree-optimization/16797] " pinskia at gcc dot gnu dot org
2004-07-30 18:11 ` steven at gcc dot gnu dot org
2004-11-03 14:40 ` nathan at gcc dot gnu dot org
2004-11-08 14:07 ` pinskia at gcc dot gnu dot org
2004-11-08 14:16 ` pinskia at gcc dot gnu dot org
2005-06-02 18:47 ` dnovillo at gcc dot gnu dot org
2005-09-10 17:59 ` pinskia at gcc dot gnu dot org
     [not found] <bug-16797-8614@http.gcc.gnu.org/bugzilla/>
2005-11-02 17:16 ` pinskia at gcc dot gnu dot org
2006-08-26  4:37 ` pinskia at gcc dot gnu dot org
     [not found] <bug-16797-4@http.gcc.gnu.org/bugzilla/>
2014-12-15 19:17 ` spop at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).