AArch64: Do not create CCMP on multiple users.

Create CMP;CCMP sequences from and/or trees does not gain us anything if
the and/or tree is materialized to a GP register anyway. While most of
the code already checked for hasOneUse() there was one important case
missing.

llvm-svn: 245640
This commit is contained in:
Matthias Braun 2015-08-20 23:33:31 +00:00
parent 549718563d
commit 266204b7dc
2 changed files with 19 additions and 3 deletions

View File

@ -1349,7 +1349,7 @@ static SDValue emitConjunctionDisjunctionTree(SelectionDAG &DAG, SDValue Val,
unsigned NZCV = AArch64CC::getNZCVToSatisfyCondCode(InvOutCC);
return emitConditionalComparison(LHS, RHS, CC, CCOp, ConditionOp, NZCV, DL,
DAG);
} else if (Opcode != ISD::AND && Opcode != ISD::OR)
} else if ((Opcode != ISD::AND && Opcode != ISD::OR) || !Val->hasOneUse())
return SDValue();
assert((Opcode == ISD::OR || !PushNegate)

View File

@ -373,8 +373,8 @@ define i32 @select_ororand(i32 %w0, i32 %w1, i32 %w2, i32 %w3) {
ret i32 %sel
}
; CHECK-LABEL: select_noccmp
define i64 @select_noccmp(i64 %v1, i64 %v2, i64 %v3, i64 %r) {
; CHECK-LABEL: select_noccmp1
define i64 @select_noccmp1(i64 %v1, i64 %v2, i64 %v3, i64 %r) {
; CHECK-NOT: CCMP
%c0 = icmp slt i64 %v1, 0
%c1 = icmp sgt i64 %v1, 13
@ -386,3 +386,19 @@ define i64 @select_noccmp(i64 %v1, i64 %v2, i64 %v3, i64 %r) {
%sel = select i1 %or, i64 0, i64 %r
ret i64 %sel
}
@g = global i32 0
; Should not use ccmp if we have to compute the or expression in an integer
; register anyway because of other users.
; CHECK-LABEL: select_noccmp2
define i64 @select_noccmp2(i64 %v1, i64 %v2, i64 %v3, i64 %r) {
; CHECK-NOT: CCMP
%c0 = icmp slt i64 %v1, 0
%c1 = icmp sgt i64 %v1, 13
%or = or i1 %c0, %c1
%sel = select i1 %or, i64 0, i64 %r
%ext = sext i1 %or to i32
store volatile i32 %ext, i32* @g
ret i64 %sel
}