From 05b3080b3c02aad92a370cb066cc8043bbb7f869 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 20 Aug 2015 23:33:31 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245640 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AArch64/AArch64ISelLowering.cpp | 2 +- test/CodeGen/AArch64/arm64-ccmp.ll | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/Target/AArch64/AArch64ISelLowering.cpp b/lib/Target/AArch64/AArch64ISelLowering.cpp index 206088dd5e8..3d1235bac0a 100644 --- a/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -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) diff --git a/test/CodeGen/AArch64/arm64-ccmp.ll b/test/CodeGen/AArch64/arm64-ccmp.ll index 446e5ce8cc4..d8ad067a1bf 100644 --- a/test/CodeGen/AArch64/arm64-ccmp.ll +++ b/test/CodeGen/AArch64/arm64-ccmp.ll @@ -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 +} -- 2.11.0