diff options
author | Magnus Lång <[email protected]> | 2016-09-24 09:42:01 +0200 |
---|---|---|
committer | Magnus Lång <[email protected]> | 2016-11-15 14:59:00 +0100 |
commit | df04801d5585f52ddc042d30873bdc95da019af6 (patch) | |
tree | b803d4b450ffbde43bac39ac2375f9c23971ce5f /lib/hipe/x86 | |
parent | 35f74834dc4130c613fea2a5483ba02ed43af2c4 (diff) | |
download | otp-df04801d5585f52ddc042d30873bdc95da019af6.tar.gz otp-df04801d5585f52ddc042d30873bdc95da019af6.tar.bz2 otp-df04801d5585f52ddc042d30873bdc95da019af6.zip |
hipe_x86: LeaToAdd peephole rule
Although LEA is useful for three-address form adds, sometimes it is used
where a normal add would have sufficed (due to the addition being the
last use of one of the operands; but RTL lowering does not know that as
it does not have liveness information). As a workaround, we convert LEA
back to ADD when the destination is the same as one of the operands.
Diffstat (limited to 'lib/hipe/x86')
-rw-r--r-- | lib/hipe/x86/hipe_x86_postpass.erl | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/hipe/x86/hipe_x86_postpass.erl b/lib/hipe/x86/hipe_x86_postpass.erl index bd232041b6..390f5bf5e7 100644 --- a/lib/hipe/x86/hipe_x86_postpass.erl +++ b/lib/hipe/x86/hipe_x86_postpass.erl @@ -183,6 +183,18 @@ peep([B = #alu{aluop=Op,src=#x86_imm{value=Val},dst=Dst}|Insns], Res, Lst) -> peep(Insns, [B|Res], Lst) end; +%% LeaToAdd +%% This rule transforms lea into add when the destination is the same as one of +%% the operands. Sound because lea is never used where the condition codes are +%% live (and would be clobbered by add). +%% ---------- +peep([#lea{mem=#x86_mem{base=#x86_temp{reg=DstR},off=Src}, + temp=Dst=#x86_temp{reg=DstR}}|Insns], Res, Lst) -> + peep(Insns, [#alu{aluop='add',src=Src,dst=Dst}|Res], [leaToAdd|Lst]); +peep([#lea{mem=#x86_mem{base=Src,off=#x86_temp{reg=DstR}}, + temp=Dst=#x86_temp{reg=DstR}}|Insns], Res, Lst) -> + peep(Insns, [#alu{aluop='add',src=Src,dst=Dst}|Res], [leaToAdd|Lst]); + %% SubToDec %% This rule turns "subl $1,Dst; jl Lab" into "decl Dst; jl Lab", which %% changes reduction counter tests to use decl instead of subl. |