#15188 closed bug (fixed)

Catch cases where both branches of an if jump to the same block.

Reported by: AndreasK Owned by: AndreasK
Priority: normal Milestone: 8.6.1
Component: Compiler (CodeGen) Version: 8.2.2
Keywords: CodeGen Cc: jmct
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D4740
Wiki Page:

Description

For one reason or the other sometimes we end up with if statements in Cmm where both branch targets are the same:

Actual example from NoFib:

       u9oL: 
           if (_c9oA::P64 != 5) goto u9p2; else goto u9p2;

Which eventually results in this code:

_u9oL:
	cmpq $5,%rbx
	jne _u9p2 <- utterly pointless
_u9p2:
	addq $16,%rbp
	jmp _c9iq

Change History (5)

comment:1 Changed 16 months ago by AndreasK

Cc: jmct added
Owner: set to AndreasK

comment:2 Changed 16 months ago by AndreasK

Status: newpatch

comment:3 Changed 16 months ago by AndreasK

Differential Rev(s): Phab:D4740

comment:4 Changed 16 months ago by Ben Gamari <ben@…>

In efea32cf/ghc:

Check if both branches of an Cmm if have the same target.

This for some reason or the other and makes it into the final
binary. I've added the check to ContFlowOpt as that seems
like a logical place for this.

In a regular nofib run there were 30 occurences of this pattern.

Test Plan: ci

Reviewers: bgamari, simonmar, dfeuer, jrtc27, tdammers

Reviewed By: bgamari, simonmar

Subscribers: tdammers, dfeuer, rwbarton, thomie, carter

GHC Trac Issues: #15188

Differential Revision: https://phabricator.haskell.org/D4740

comment:5 Changed 16 months ago by bgamari

Resolution: fixed
Status: patchclosed
Note: See TracTickets for help on using tickets.