llvm.org GIT mirror llvm / 79f56c9
Fix a compiler crash where a Glue value had multiple uses. Radar 9049552. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127198 91177308-0d34-0410-b5e6-96231b3b80d8 Bob Wilson 9 years ago
3 changed file(s) with 46 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
25262526 return DAG.getNode(ARMISD::FMSTAT, dl, MVT::Glue, Cmp);
25272527 }
25282528
2529 /// duplicateCmp - Glue values can have only one use, so this function
2530 /// duplicates a comparison node.
2531 SDValue
2532 ARMTargetLowering::duplicateCmp(SDValue Cmp, SelectionDAG &DAG) const {
2533 unsigned Opc = Cmp.getOpcode();
2534 DebugLoc DL = Cmp.getDebugLoc();
2535 if (Opc == ARMISD::CMP || Opc == ARMISD::CMPZ)
2536 return DAG.getNode(Opc, DL, MVT::Glue, Cmp.getOperand(0),Cmp.getOperand(1));
2537
2538 assert(Opc == ARMISD::FMSTAT && "unexpected comparison operation");
2539 Cmp = Cmp.getOperand(0);
2540 Opc = Cmp.getOpcode();
2541 if (Opc == ARMISD::CMPFP)
2542 Cmp = DAG.getNode(Opc, DL, MVT::Glue, Cmp.getOperand(0),Cmp.getOperand(1));
2543 else {
2544 assert(Opc == ARMISD::CMPFPw0 && "unexpected operand of FMSTAT");
2545 Cmp = DAG.getNode(Opc, DL, MVT::Glue, Cmp.getOperand(0));
2546 }
2547 return DAG.getNode(ARMISD::FMSTAT, DL, MVT::Glue, Cmp);
2548 }
2549
25292550 SDValue ARMTargetLowering::LowerSELECT(SDValue Op, SelectionDAG &DAG) const {
25302551 SDValue Cond = Op.getOperand(0);
25312552 SDValue SelectTrue = Op.getOperand(1);
25612582 EVT VT = Cond.getValueType();
25622583 SDValue ARMcc = Cond.getOperand(2);
25632584 SDValue CCR = Cond.getOperand(3);
2564 SDValue Cmp = Cond.getOperand(4);
2585 SDValue Cmp = duplicateCmp(Cond.getOperand(4), DAG);
25652586 return DAG.getNode(ARMISD::CMOV, dl, VT, True, False, ARMcc, CCR, Cmp);
25662587 }
25672588 }
458458 SDValue &ARMcc, SelectionDAG &DAG, DebugLoc dl) const;
459459 SDValue getVFPCmp(SDValue LHS, SDValue RHS,
460460 SelectionDAG &DAG, DebugLoc dl) const;
461 SDValue duplicateCmp(SDValue Cmp, SelectionDAG &DAG) const;
461462
462463 SDValue OptimizeVFPBrcond(SDValue Op, SelectionDAG &DAG) const;
463464
8989 %tmp1 = select i1 %tmp, float 0x3FF3BE76C0000000, float 0x40030E9A20000000
9090 ret float %tmp1
9191 }
92
93 ;
94 ; Glue values can only have a single use, but the following test exposed a
95 ; case where a SELECT was lowered with 2 uses of a comparison, causing the
96 ; scheduler to assert.
97 ; CHECK-VFP: f9:
98
99 declare i8* @objc_msgSend(i8*, i8*, ...)
100 define void @f9() optsize {
101 entry:
102 %cmp = icmp eq i8* undef, inttoptr (i32 4 to i8*)
103 %conv191 = select i1 %cmp, float -3.000000e+00, float 0.000000e+00
104 %conv195 = select i1 %cmp, double -1.000000e+00, double 0.000000e+00
105 %add = fadd double %conv195, 1.100000e+01
106 %conv196 = fptrunc double %add to float
107 %add201 = fadd float undef, %conv191
108 %tmp484 = bitcast float %conv196 to i32
109 %tmp478 = bitcast float %add201 to i32
110 %tmp490 = insertvalue [2 x i32] undef, i32 %tmp484, 0
111 %tmp493 = insertvalue [2 x i32] %tmp490, i32 %tmp478, 1
112 call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, [2 x i32], i32, float)*)(i8* undef, i8* undef, [2 x i32] %tmp493, i32 0, float 1.000000e+00) optsize
113 ret void
114 }