Skip to content

Commit 9364ca1

Browse files
committed
Merging r245741:
------------------------------------------------------------------------ r245741 | hfinkel | 2015-08-21 17:34:24 -0400 (Fri, 21 Aug 2015) | 8 lines [PowerPC] PPCVSXFMAMutate should not segfault on undef input registers When PPCVSXFMAMutate would look at the input addend register, it would get its input value number. This would fail, however, if the register was undef, causing a segfault. Don't segfault (just skip such FMA instructions). Fixes the test case from PR24542 (although that may have been over-reduced). ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_37@252132 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 0776fac commit 9364ca1

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/Target/PowerPC/PPCVSXFMAMutate.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ namespace {
103103

104104
VNInfo *AddendValNo =
105105
LIS->getInterval(MI->getOperand(1).getReg()).Query(FMAIdx).valueIn();
106+
if (!AddendValNo) {
107+
// This can be null if the register is undef.
108+
continue;
109+
}
110+
106111
MachineInstr *AddendMI = LIS->getInstructionFromIndex(AddendValNo->def);
107112

108113
// The addend and this instruction must be in the same block.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
; RUN: llc < %s | FileCheck %s
2+
target datalayout = "e-m:e-i64:64-n32:64"
3+
target triple = "powerpc64le-unknown-linux-gnu"
4+
5+
; Function Attrs: nounwind
6+
define void @acosh_float8() #0 {
7+
entry:
8+
br i1 undef, label %if.then, label %if.end
9+
10+
if.then: ; preds = %entry
11+
%0 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> undef, <4 x float> <float 0x3FE62E4200000000, float 0x3FE62E4200000000, float 0x3FE62E4200000000, float 0x3FE62E4200000000>, <4 x float> undef) #0
12+
%astype.i.i.74.i = bitcast <4 x float> %0 to <4 x i32>
13+
%and.i.i.76.i = and <4 x i32> %astype.i.i.74.i, undef
14+
%or.i.i.79.i = or <4 x i32> %and.i.i.76.i, undef
15+
%astype5.i.i.80.i = bitcast <4 x i32> %or.i.i.79.i to <4 x float>
16+
%1 = shufflevector <4 x float> %astype5.i.i.80.i, <4 x float> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
17+
%2 = shufflevector <8 x float> undef, <8 x float> %1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11>
18+
store <8 x float> %2, <8 x float>* undef, align 32
19+
br label %if.end
20+
21+
; CHECK-LABEL: @acosh_float8
22+
; CHECK: xvmaddasp
23+
24+
if.end: ; preds = %if.then, %entry
25+
ret void
26+
}
27+
28+
; Function Attrs: nounwind readnone
29+
declare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>) #1
30+
31+
attributes #0 = { nounwind }
32+
attributes #1 = { nounwind readnone }
33+

0 commit comments

Comments
 (0)