HomePhabricator

[PowerPC] Combine ADD to ADDZE

Description

[PowerPC] Combine ADD to ADDZE

On the ppc64le platform, if ir has the following form,

define i64 @addze1(i64 %x, i64 %z) local_unnamed_addr #0 {
entry:

%cmp = icmp ne i64 %z, CONSTANT      (-32767 <= CONSTANT <= 32768)
%conv1 = zext i1 %cmp to i64
%add = add nsw i64 %conv1, %x
ret i64 %add

}
we can optimize it to the form below.

     when C == 0
 --> addze X, (addic Z, -1))
/

add X, (zext(setne Z, C))--

\    when -32768 <= -C <= 32767 && C != 0
 --> addze X, (addic (addi Z, -C), -1)

Patch By: HLJ2009 (Li Jia He)
Differential Revision: https://reviews.llvm.org/D51403
Reviewed By: Nemanjai

Details

Committed
qshanzSep 7 2018, 12:56 AM
Reviewer
nemanjai
Differential Revision
D51403: [PowerPC] Combine ADD to ADDZE
Parents
rL341633: [IndVars] Set Changed when we delete dead instructions. PR38855
Branches
Unknown
Tags
Unknown