llvm.org GIT mirror llvm / a860a07
[X86] When handling addcarry intrinsic, create the flag result with the correct type so we don't crash if we use a memory instruction Summary: Previously we were creating the flag result with MVT::Other which is interpretted as a Chain node. If we used a memory form of the instruction we would end up with a copyToReg that consumed the chain result of the adcx instruction instead of the flag result. Pretty sure we should be using MVT::i32 here, that's what we do other places we create these node types. We should probably consider this for 5.0 as well. Reviewers: RKSimon, zvi, spatel Reviewed By: RKSimon Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D36645 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310784 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 2 years ago
2 changed file(s) with 29 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
2061720617 }
2061820618 // ADC/ADCX/SBB
2061920619 case ADX: {
20620 SDVTList CFVTs = DAG.getVTList(Op->getValueType(0), MVT::Other);
20621 SDVTList VTs = DAG.getVTList(Op.getOperand(3)->getValueType(0), MVT::Other);
20620 SDVTList CFVTs = DAG.getVTList(Op->getValueType(0), MVT::i32);
20621 SDVTList VTs = DAG.getVTList(Op.getOperand(3)->getValueType(0), MVT::i32);
2062220622 SDValue GenCF = DAG.getNode(X86ISD::ADD, dl, CFVTs, Op.getOperand(2),
2062320623 DAG.getConstant(-1, dl, MVT::i8));
2062420624 SDValue Res = DAG.getNode(IntrData->Opc0, dl, VTs, Op.getOperand(3),
7474 ret i8 %ret;
7575 }
7676
77 ; Try a version with loads. Previously we crashed on this.
78 define i32 @load_crash(i64* nocapture readonly %a, i64* nocapture readonly %b, i64* %res) {
79 ; CHECK-LABEL: load_crash
80 ; CHECK: addb
81 ; ADX: adcxq
82 ; CHECK: setb
83 ; CHECK: retq
84 %1 = load i64, i64* %a, align 8
85 %2 = load i64, i64* %b, align 8
86 %3 = bitcast i64* %res to i8*
87 %4 = tail call i8 @llvm.x86.addcarryx.u64(i8 0, i64 %1, i64 %2, i8* %3)
88 %conv = zext i8 %4 to i32
89 ret i32 %conv
90 }
91
92 ; Try a really simple all zero input case, which also used to crash
93 define void @allzeros() {
94 ; CHECK-LABEL: allzeros
95 ; CHECK: xorl
96 ; CHECK: addb
97 ; CHECK: sbbq
98 ; CHECK: andl
99 ; CHECK: retq
100 entry:
101 %0 = tail call i8 @llvm.x86.addcarryx.u64(i8 0, i64 0, i64 0, i8* null)
102 ret void
103 }