[llvm] r258536 - [NVPTX] expand mul_lohi to mul_lo and mul_hi
Jingyue Wu via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 22 11:47:27 PST 2016
Author: jingyue
Date: Fri Jan 22 13:47:26 2016
New Revision: 258536
URL: http://llvm.org/viewvc/llvm-project?rev=258536&view=rev
Log:
[NVPTX] expand mul_lohi to mul_lo and mul_hi
Summary: Fixes PR26186.
Reviewers: grosser, jholewinski
Subscribers: jholewinski, llvm-commits
Differential Revision: http://reviews.llvm.org/D16479
Modified:
llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
llvm/trunk/test/CodeGen/NVPTX/arithmetic-int.ll
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp?rev=258536&r1=258535&r2=258536&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp Fri Jan 22 13:47:26 2016
@@ -273,6 +273,10 @@ NVPTXTargetLowering::NVPTXTargetLowering
// PTX does not directly support SELP of i1, so promote to i32 first
setOperationAction(ISD::SELECT, MVT::i1, Custom);
+ // PTX cannot multiply two i64s in a single instruction.
+ setOperationAction(ISD::SMUL_LOHI, MVT::i64, Expand);
+ setOperationAction(ISD::UMUL_LOHI, MVT::i64, Expand);
+
// We have some custom DAG combine patterns for these nodes
setTargetDAGCombine(ISD::ADD);
setTargetDAGCombine(ISD::AND);
Modified: llvm/trunk/test/CodeGen/NVPTX/arithmetic-int.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/NVPTX/arithmetic-int.ll?rev=258536&r1=258535&r2=258536&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/NVPTX/arithmetic-int.ll (original)
+++ llvm/trunk/test/CodeGen/NVPTX/arithmetic-int.ll Fri Jan 22 13:47:26 2016
@@ -29,6 +29,30 @@ define i64 @mul_i64(i64 %a, i64 %b) {
ret i64 %ret
}
+define i64 @umul_lohi_i64(i64 %a) {
+; CHECK-LABEL: umul_lohi_i64(
+entry:
+ %0 = zext i64 %a to i128
+ %1 = mul i128 %0, 288
+; CHECK: mul.lo.{{u|s}}64
+; CHECK: mul.hi.{{u|s}}64
+ %2 = lshr i128 %1, 1
+ %3 = trunc i128 %2 to i64
+ ret i64 %3
+}
+
+define i64 @smul_lohi_i64(i64 %a) {
+; CHECK-LABEL: smul_lohi_i64(
+entry:
+ %0 = sext i64 %a to i128
+ %1 = mul i128 %0, 288
+; CHECK: mul.lo.{{u|s}}64
+; CHECK: mul.hi.{{u|s}}64
+ %2 = ashr i128 %1, 1
+ %3 = trunc i128 %2 to i64
+ ret i64 %3
+}
+
define i64 @sdiv_i64(i64 %a, i64 %b) {
; CHECK: div.s64 %rd{{[0-9]+}}, %rd{{[0-9]+}}, %rd{{[0-9]+}}
; CHECK: ret
More information about the llvm-commits
mailing list