[PATCH] [ARM] Fix issue with SMLAL (Signed Multiply Accumulate Long) lowering
Jyoti Allur
jyoti.allur at samsung.com
Wed Jan 21 07:24:07 PST 2015
Hi Tim,
You were right, the original issue existed with the buggy opcode checking which is now corrected without additional checks.
Thanks.
http://reviews.llvm.org/D6998
Files:
../llvm/lib/Target/ARM/ARMISelLowering.cpp
../llvm/test/CodeGen/ARM/longMAC.ll
Index: ../llvm/lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- ../llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ ../llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -8065,7 +8065,6 @@
unsigned FinalOpc = (Opc == ISD::SMUL_LOHI) ? ARMISD::SMLAL : ARMISD::UMLAL;
// Figure out the high and low input values to the MLAL node.
- SDValue* HiMul = &MULOp;
SDValue* HiAdd = nullptr;
SDValue* LoMul = nullptr;
SDValue* LowAdd = nullptr;
@@ -8075,12 +8074,15 @@
else
HiAdd = &AddeOp0;
+ // When both operands of ADDC are a result from different ISD::SMUL_LOHI,
+ // make sure LoMul and LowAdd are taken from correct ISD::SMUL_LOHI result.
- if (AddcOp0->getOpcode() == Opc) {
+ if (AddcOp0 == MULOp.getValue(0)) {
LoMul = &AddcOp0;
LowAdd = &AddcOp1;
}
- if (AddcOp1->getOpcode() == Opc) {
+
+ if (AddcOp1 == MULOp.getValue(1)) {
LoMul = &AddcOp1;
LowAdd = &AddcOp0;
}
@@ -8088,9 +8090,6 @@
if (!LoMul)
return SDValue();
- if (LoMul->getNode() != HiMul->getNode())
- return SDValue();
-
// Create the merged node.
SelectionDAG &DAG = DCI.DAG;
Index: ../llvm/test/CodeGen/ARM/longMAC.ll
===================================================================
--- ../llvm/test/CodeGen/ARM/longMAC.ll
+++ ../llvm/test/CodeGen/ARM/longMAC.ll
@@ -75,3 +75,31 @@
%add = add i64 %mul, %c
ret i64 %add
}
+
+define i64 @MACLongTest6(i32 %a, i32 %b, i32 %c, i32 %d) {
+;CHECK-LABEL: MACLongTest6:
+;CHECK: smull r12, lr, r1, r0
+;CHECK: smlal r12, lr, r3, r2
+ %conv = sext i32 %a to i64
+ %conv1 = sext i32 %b to i64
+ %mul = mul nsw i64 %conv1, %conv
+ %conv2 = sext i32 %c to i64
+ %conv3 = sext i32 %d to i64
+ %mul4 = mul nsw i64 %conv3, %conv2
+ %add = add nsw i64 %mul4, %mul
+ ret i64 %add
+}
+
+define i64 @MACLongTest7(i64 %acc, i32 %lhs, i32 %rhs) {
+;CHECK-LABEL: MACLongTest7:
+;CHECK-NOT: smlal
+ %conv = sext i32 %lhs to i64
+ %conv1 = sext i32 %rhs to i64
+ %mul = mul nsw i64 %conv1, %conv
+ %shl = shl i64 %mul, 32
+ %shr = lshr i64 %mul, 32
+ %or = or i64 %shl, %shr
+ %add = add i64 %or, %acc
+ ret i64 %add
+}
+
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6998.18513.patch
Type: text/x-patch
Size: 2171 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150121/91cdcd6e/attachment.bin>
More information about the llvm-commits
mailing list