Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 8c8ecd9

Browse files
TimNNarielb1
authored andcommitted
Merge pull request #72 from TimNN/ppc-backport-4.0
Backport: "[PowerPC] multiply-with-overflow might use the CTR register"
2 parents a1acabd + b21791d commit 8c8ecd9

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

lib/Target/PowerPC/PPCCTRLoops.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -298,15 +298,17 @@ bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) {
298298
return true;
299299
else
300300
continue; // ISD::FCOPYSIGN is never a library call.
301-
case Intrinsic::sqrt: Opcode = ISD::FSQRT; break;
302-
case Intrinsic::floor: Opcode = ISD::FFLOOR; break;
303-
case Intrinsic::ceil: Opcode = ISD::FCEIL; break;
304-
case Intrinsic::trunc: Opcode = ISD::FTRUNC; break;
305-
case Intrinsic::rint: Opcode = ISD::FRINT; break;
306-
case Intrinsic::nearbyint: Opcode = ISD::FNEARBYINT; break;
307-
case Intrinsic::round: Opcode = ISD::FROUND; break;
308-
case Intrinsic::minnum: Opcode = ISD::FMINNUM; break;
309-
case Intrinsic::maxnum: Opcode = ISD::FMAXNUM; break;
301+
case Intrinsic::sqrt: Opcode = ISD::FSQRT; break;
302+
case Intrinsic::floor: Opcode = ISD::FFLOOR; break;
303+
case Intrinsic::ceil: Opcode = ISD::FCEIL; break;
304+
case Intrinsic::trunc: Opcode = ISD::FTRUNC; break;
305+
case Intrinsic::rint: Opcode = ISD::FRINT; break;
306+
case Intrinsic::nearbyint: Opcode = ISD::FNEARBYINT; break;
307+
case Intrinsic::round: Opcode = ISD::FROUND; break;
308+
case Intrinsic::minnum: Opcode = ISD::FMINNUM; break;
309+
case Intrinsic::maxnum: Opcode = ISD::FMAXNUM; break;
310+
case Intrinsic::umul_with_overflow: Opcode = ISD::UMULO; break;
311+
case Intrinsic::smul_with_overflow: Opcode = ISD::SMULO; break;
310312
}
311313
}
312314

test/CodeGen/PowerPC/ctrloop-i128.ll

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
; RUN: llc -O1 -verify-machineinstrs < %s
2+
target datalayout = "E-m:e-i64:64-n32:64"
3+
target triple = "powerpc64-unknown-linux-gnu"
4+
5+
; Function Attrs: uwtable
6+
define fastcc void @_Crash_Fn() unnamed_addr #0 {
7+
entry-block:
8+
br label %_Label_0
9+
10+
_Label_0: ; preds = %_Label_0, %entry-block
11+
%result.0138 = phi i128 [ %5, %_Label_0 ], [ 0, %entry-block ]
12+
%iter.sroa.0.0137 = phi i8* [ %0, %_Label_0 ], [ undef, %entry-block ]
13+
%0 = getelementptr inbounds i8, i8* %iter.sroa.0.0137, i64 1
14+
%1 = tail call { i128, i1 } @llvm.smul.with.overflow.i128(i128 %result.0138, i128 undef) #2
15+
%2 = extractvalue { i128, i1 } %1, 0
16+
%3 = tail call { i128, i1 } @llvm.sadd.with.overflow.i128(i128 %2, i128 0) #2
17+
%4 = extractvalue { i128, i1 } %3, 1
18+
%5 = extractvalue { i128, i1 } %3, 0
19+
%6 = icmp eq i8* %0, null
20+
br i1 %6, label %bb66.loopexit, label %_Label_0
21+
22+
bb66.loopexit: ; preds = %_Label_0
23+
unreachable
24+
}
25+
26+
; Function Attrs: nounwind readnone
27+
declare { i128, i1 } @llvm.sadd.with.overflow.i128(i128, i128) #1
28+
29+
; Function Attrs: nounwind readnone
30+
declare { i128, i1 } @llvm.smul.with.overflow.i128(i128, i128) #1
31+
32+
attributes #0 = { uwtable }
33+
attributes #1 = { nounwind readnone }
34+
attributes #2 = { nounwind }

0 commit comments

Comments
 (0)