Skip to content

Commit 24c9818

Browse files
author
Sjoerd Meijer
committedAug 23, 2017
[AArch64] ISel legalization debug messages. NFCI.
Debugging AArch64 instruction legalization and custom lowering is really an unpleasant experience because it shows nodes that appear out of thin air. In commit r311444, some debug messages have been added to SelectionDAG, the target independent part, and this patch adds some AArch64 specific messages. Differential Revision: https://reviews.llvm.org/D36964 llvm-svn: 311533
1 parent 4a9c260 commit 24c9818

File tree

1 file changed

+47
-12
lines changed

1 file changed

+47
-12
lines changed
 

‎llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

+47-12
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,9 @@ static void changeVectorFPCCToAArch64CC(ISD::CondCode CC,
14361436

14371437
static bool isLegalArithImmed(uint64_t C) {
14381438
// Matches AArch64DAGToDAGISel::SelectArithImmed().
1439-
return (C >> 12 == 0) || ((C & 0xFFFULL) == 0 && C >> 24 == 0);
1439+
bool IsLegal = (C >> 12 == 0) || ((C & 0xFFFULL) == 0 && C >> 24 == 0);
1440+
DEBUG(dbgs() << "Is imm " << C << " legal: " << (IsLegal ? "yes\n" : "no\n"));
1441+
return IsLegal;
14401442
}
14411443

14421444
static SDValue emitComparison(SDValue LHS, SDValue RHS, ISD::CondCode CC,
@@ -2546,6 +2548,9 @@ SDValue AArch64TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
25462548

25472549
SDValue AArch64TargetLowering::LowerOperation(SDValue Op,
25482550
SelectionDAG &DAG) const {
2551+
DEBUG(dbgs() << "Custom lowering: ");
2552+
DEBUG(Op.dump());
2553+
25492554
switch (Op.getOpcode()) {
25502555
default:
25512556
llvm_unreachable("unimplemented operand");
@@ -4880,22 +4885,46 @@ SDValue AArch64TargetLowering::LowerShiftLeftParts(SDValue Op,
48804885

48814886
bool AArch64TargetLowering::isOffsetFoldingLegal(
48824887
const GlobalAddressSDNode *GA) const {
4883-
// The AArch64 target doesn't support folding offsets into global addresses.
4888+
DEBUG(dbgs() << "Skipping offset folding global address: ");
4889+
DEBUG(GA->dump());
4890+
DEBUG(dbgs() << "AArch64 doesn't support folding offsets into global "
4891+
"addresses\n");
48844892
return false;
48854893
}
48864894

48874895
bool AArch64TargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT) const {
48884896
// We can materialize #0.0 as fmov $Rd, XZR for 64-bit and 32-bit cases.
48894897
// FIXME: We should be able to handle f128 as well with a clever lowering.
4890-
if (Imm.isPosZero() && (VT == MVT::f64 || VT == MVT::f32))
4898+
if (Imm.isPosZero() && (VT == MVT::f64 || VT == MVT::f32)) {
4899+
DEBUG(dbgs() << "Legal fp imm: materialize 0 using the zero register\n");
48914900
return true;
4901+
}
4902+
4903+
StringRef FPType;
4904+
bool IsLegal = false;
4905+
const StringRef Msg = "Is legal ";
4906+
4907+
if (VT == MVT::f64) {
4908+
FPType = "f64";
4909+
IsLegal = AArch64_AM::getFP64Imm(Imm) != -1;
4910+
} else if (VT == MVT::f32) {
4911+
FPType = "f32";
4912+
IsLegal = AArch64_AM::getFP32Imm(Imm) != -1;
4913+
} else if (VT == MVT::f16 && Subtarget->hasFullFP16()) {
4914+
FPType = "f16";
4915+
IsLegal = AArch64_AM::getFP16Imm(Imm) != -1;
4916+
}
4917+
4918+
if (IsLegal) {
4919+
DEBUG(dbgs() << Msg << FPType << " imm value: yes\n");
4920+
return true;
4921+
}
4922+
4923+
if (!FPType.empty())
4924+
DEBUG(dbgs() << Msg << FPType << " imm value: no\n");
4925+
else
4926+
DEBUG(dbgs() << Msg << "fp imm: no, unsupported fp type\n");
48924927

4893-
if (VT == MVT::f64)
4894-
return AArch64_AM::getFP64Imm(Imm) != -1;
4895-
else if (VT == MVT::f32)
4896-
return AArch64_AM::getFP32Imm(Imm) != -1;
4897-
else if (VT == MVT::f16 && Subtarget->hasFullFP16())
4898-
return AArch64_AM::getFP16Imm(Imm) != -1;
48994928
return false;
49004929
}
49014930

@@ -7835,12 +7864,17 @@ EVT AArch64TargetLowering::getOptimalMemOpType(uint64_t Size, unsigned DstAlign,
78357864

78367865
// 12-bit optionally shifted immediates are legal for adds.
78377866
bool AArch64TargetLowering::isLegalAddImmediate(int64_t Immed) const {
7838-
// Avoid UB for INT64_MIN.
7839-
if (Immed == std::numeric_limits<int64_t>::min())
7867+
if (Immed == std::numeric_limits<int64_t>::min()) {
7868+
DEBUG(dbgs() << "Illegal add imm " << Immed << ": avoid UB for INT64_MIN\n");
78407869
return false;
7870+
}
78417871
// Same encoding for add/sub, just flip the sign.
78427872
Immed = std::abs(Immed);
7843-
return ((Immed >> 12) == 0 || ((Immed & 0xfff) == 0 && Immed >> 24 == 0));
7873+
bool IsLegal = ((Immed >> 12) == 0 ||
7874+
((Immed & 0xfff) == 0 && Immed >> 24 == 0));
7875+
DEBUG(dbgs() << "Is " << Immed << " legal add imm: " <<
7876+
(IsLegal ? "yes" : "no") << "\n");
7877+
return IsLegal;
78447878
}
78457879

78467880
// Integer comparisons are implemented with ADDS/SUBS, so the range of valid
@@ -10290,6 +10324,7 @@ SDValue AArch64TargetLowering::PerformDAGCombine(SDNode *N,
1029010324
SelectionDAG &DAG = DCI.DAG;
1029110325
switch (N->getOpcode()) {
1029210326
default:
10327+
DEBUG(dbgs() << "Custom combining: skipping\n");
1029310328
break;
1029410329
case ISD::ADD:
1029510330
case ISD::SUB:

0 commit comments

Comments
 (0)
Please sign in to comment.