llvm.org GIT mirror llvm / 0ac3fc2
Fix a (u)comiss intrinsic lowering bug. It was using anyext which can return junk in higher bits. Patch by Nate Begeman. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54903 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 11 years ago
4 changed file(s) with 13 addition(s) and 101 deletion(s). Raw diff Collapse all Expand all
15141514 SDValue N0 = Node->getOperand(0);
15151515 // Get the subregsiter index for the type to extend.
15161516 MVT N0VT = N0.getValueType();
1517 // FIXME: In x86-32, 8-bit value may be in AH, etc. which don't have
1518 // super-registers.
15171519 unsigned Idx = (N0VT == MVT::i32) ? X86::SUBREG_32BIT :
15181520 (N0VT == MVT::i16) ? X86::SUBREG_16BIT :
15191521 (Subtarget->is64Bit()) ? X86::SUBREG_8BIT : 0;
54185418
54195419 SDValue Cond = DAG.getNode(Opc, MVT::i32, LHS, RHS);
54205420 SDValue SetCC = DAG.getNode(X86ISD::SETCC, MVT::i8,
5421 DAG.getConstant(X86CC, MVT::i8), Cond);
5422 return DAG.getNode(ISD::ANY_EXTEND, MVT::i32, SetCC);
5421 DAG.getConstant(X86CC, MVT::i8), Cond);
5422 return DAG.getNode(ISD::ZERO_EXTEND, MVT::i32, SetCC);
54235423 }
54245424
54255425 // Fix vector shift instructions where the last operand is a non-immediate
0 ; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin | grep movzbl
1
2 define i32 @foo(<4 x float> %a, <4 x float> %b) nounwind {
3 entry:
4 tail call i32 @llvm.x86.sse.ucomige.ss( <4 x float> %a, <4 x float> %b ) nounwind readnone
5 ret i32 %0
6 }
7
8 declare i32 @llvm.x86.sse.ucomige.ss(<4 x float>, <4 x float>) nounwind readnone
None ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | grep "phi double" | count 1
1
2 define void @foobar(i32 %n) nounwind {
3 entry:
4 icmp eq i32 %n, 0 ; :0 [#uses=2]
5 br i1 %0, label %return, label %bb.nph
6
7 bb.nph: ; preds = %entry
8 %umax = select i1 %0, i32 1, i32 %n ; [#uses=1]
9 br label %bb
10
11 bb: ; preds = %bb, %bb.nph
12 %i.03 = phi i32 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; [#uses=3]
13 tail call void @bar( i32 %i.03 ) nounwind
14 uitofp i32 %i.03 to double ; :1 [#uses=1]
15 tail call void @foo( double %1 ) nounwind
16 %indvar.next = add i32 %i.03, 1 ; [#uses=2]
17 %exitcond = icmp eq i32 %indvar.next, %umax ; [#uses=1]
18 br i1 %exitcond, label %return, label %bb
19
20 return: ; preds = %bb, %entry
21 ret void
22 }
23
24 ; Unable to eliminate cast because the mantissa bits for double are not enough
25 ; to hold all of i64 IV bits.
26 define void @foobar2(i64 %n) nounwind {
27 entry:
28 icmp eq i64 %n, 0 ; :0 [#uses=2]
29 br i1 %0, label %return, label %bb.nph
30
31 bb.nph: ; preds = %entry
32 %umax = select i1 %0, i64 1, i64 %n ; [#uses=1]
33 br label %bb
34
35 bb: ; preds = %bb, %bb.nph
36 %i.03 = phi i64 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; [#uses=3]
37 trunc i64 %i.03 to i32 ; :1 [#uses=1]
38 tail call void @bar( i32 %1 ) nounwind
39 uitofp i64 %i.03 to double ; :2 [#uses=1]
40 tail call void @foo( double %2 ) nounwind
41 %indvar.next = add i64 %i.03, 1 ; [#uses=2]
42 %exitcond = icmp eq i64 %indvar.next, %umax ; [#uses=1]
43 br i1 %exitcond, label %return, label %bb
44
45 return: ; preds = %bb, %entry
46 ret void
47 }
48
49 ; Unable to eliminate cast due to potentional overflow.
50 define void @foobar3() nounwind {
51 entry:
52 tail call i32 (...)* @nn( ) nounwind ; :0 [#uses=1]
53 icmp eq i32 %0, 0 ; :1 [#uses=1]
54 br i1 %1, label %return, label %bb
55
56 bb: ; preds = %bb, %entry
57 %i.03 = phi i32 [ 0, %entry ], [ %3, %bb ] ; [#uses=3]
58 tail call void @bar( i32 %i.03 ) nounwind
59 uitofp i32 %i.03 to double ; :2 [#uses=1]
60 tail call void @foo( double %2 ) nounwind
61 add i32 %i.03, 1 ; :3 [#uses=2]
62 tail call i32 (...)* @nn( ) nounwind ; :4 [#uses=1]
63 icmp ugt i32 %4, %3 ; :5 [#uses=1]
64 br i1 %5, label %bb, label %return
65
66 return: ; preds = %bb, %entry
67 ret void
68 }
69
70 ; Unable to eliminate cast due to overflow.
71 define void @foobar4() nounwind {
72 entry:
73 br label %bb.nph
74
75 bb.nph: ; preds = %entry
76 br label %bb
77
78 bb: ; preds = %bb, %bb.nph
79 %i.03 = phi i8 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; [#uses=3]
80 %tmp2 = sext i8 %i.03 to i32 ; :0 [#uses=1]
81 tail call void @bar( i32 %tmp2 ) nounwind
82 %tmp3 = uitofp i8 %i.03 to double ; :1 [#uses=1]
83 tail call void @foo( double %tmp3 ) nounwind
84 %indvar.next = add i8 %i.03, 1 ; [#uses=2]
85 %tmp = sext i8 %indvar.next to i32
86 %exitcond = icmp eq i32 %tmp, 32767 ; [#uses=1]
87 br i1 %exitcond, label %return, label %bb
88
89 return: ; preds = %bb, %entry
90 ret void
91 }
92
93 declare void @bar(i32)
94
95 declare void @foo(double)
96
97 declare i32 @nn(...)
98