Opened 8 years ago

Last modified 4 years ago

#5171 new feature request

Misfeature of Cmm optimiser: no way to extract a branch of expression into a separate statement

Reported by: rtvd Owned by:
Priority: low Milestone:
Component: Compiler Version: 7.0.3
Keywords: Cmm optimisation Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by igloo)

AFAIK, optimisations in Cmm are performed using cmmMachOpFold. However, this function is pure and does not allow detaching a branch of expression in order to make sure that it is executed only once.

Let's say we have (Op1 arg1 arg2) and we want to transform it to (Op2 arg1 (Op3 arg2 arg1)). Doing this would mean that arg1 would be computed more than once. Instead, the following should be possible:

arg1_reg <- arg1
(Op2 arg1_reg (Op3 arg2 arg1_reg))

The lack of this feature already stops one of optimisations from happening in most cases. See:

       CmmReg _ <- x -> -- We duplicate x below, hence require
        -- it is a reg.  FIXME: remove this restriction.

in CmmOpt.hs.

There is a number of other useful optimisations which can be implemented only with this feature available.

Change History (8)

comment:1 Changed 8 years ago by igloo

Description: modified (diff)

comment:2 Changed 8 years ago by igloo

Milestone: 7.4.1

comment:3 Changed 8 years ago by igloo

Milestone: 7.4.17.6.1
Priority: normallow

comment:4 Changed 7 years ago by igloo

Milestone: 7.6.17.6.2

comment:5 Changed 5 years ago by thoughtpolice

Milestone: 7.6.27.10.1

Moving to 7.10.1.

comment:6 Changed 5 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:7 Changed 4 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

comment:8 Changed 4 years ago by thomie

Milestone: 8.0.1
Note: See TracTickets for help on using tickets.