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

Commit 801c03e

Browse files
committed
Merging r310784:
------------------------------------------------------------------------ r310784 | ctopper | 2017-08-12 13:19:44 -0700 (Sat, 12 Aug 2017) | 16 lines [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/branches/release_50@310899 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 492b2bc commit 801c03e

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

lib/Target/X86/X86ISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20671,8 +20671,8 @@ static SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, const X86Subtarget &Subtarget,
2067120671
}
2067220672
// ADC/ADCX/SBB
2067320673
case ADX: {
20674-
SDVTList CFVTs = DAG.getVTList(Op->getValueType(0), MVT::Other);
20675-
SDVTList VTs = DAG.getVTList(Op.getOperand(3)->getValueType(0), MVT::Other);
20674+
SDVTList CFVTs = DAG.getVTList(Op->getValueType(0), MVT::i32);
20675+
SDVTList VTs = DAG.getVTList(Op.getOperand(3)->getValueType(0), MVT::i32);
2067620676
SDValue GenCF = DAG.getNode(X86ISD::ADD, dl, CFVTs, Op.getOperand(2),
2067720677
DAG.getConstant(-1, dl, MVT::i8));
2067820678
SDValue Res = DAG.getNode(IntrData->Opc0, dl, VTs, Op.getOperand(3),

test/CodeGen/X86/adx-intrinsics.ll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,30 @@ define i8 @test_subborrow_u64(i8 %c, i64 %a, i64 %b, i8* %ptr) {
7575
ret i8 %ret;
7676
}
7777

78+
; Try a version with loads. Previously we crashed on this.
79+
define i32 @load_crash(i64* nocapture readonly %a, i64* nocapture readonly %b, i64* %res) {
80+
; CHECK-LABEL: load_crash
81+
; CHECK: addb
82+
; ADX: adcxq
83+
; CHECK: setb
84+
; CHECK: retq
85+
%1 = load i64, i64* %a, align 8
86+
%2 = load i64, i64* %b, align 8
87+
%3 = bitcast i64* %res to i8*
88+
%4 = tail call i8 @llvm.x86.addcarryx.u64(i8 0, i64 %1, i64 %2, i8* %3)
89+
%conv = zext i8 %4 to i32
90+
ret i32 %conv
91+
}
92+
93+
; Try a really simple all zero input case, which also used to crash
94+
define void @allzeros() {
95+
; CHECK-LABEL: allzeros
96+
; CHECK: xorl
97+
; CHECK: addb
98+
; CHECK: sbbq
99+
; CHECK: andl
100+
; CHECK: retq
101+
entry:
102+
%0 = tail call i8 @llvm.x86.addcarryx.u64(i8 0, i64 0, i64 0, i8* null)
103+
ret void
104+
}

0 commit comments

Comments
 (0)