Skip to content

Commit ff09962

Browse files
committed
Reimplement UAddc with simplified named struct handling
1 parent 21cbec9 commit ff09962

File tree

5 files changed

+2
-20
lines changed

5 files changed

+2
-20
lines changed

llvm/lib/Target/DirectX/DXIL.td

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,7 @@ def UMin : DXILOp<40, binary> {
741741

742742
def UAddc : DXILOp<44, binaryWithCarryOrBorrow > {
743743
let Doc = "Unsigned 32-bit integer arithmetic add with carry. uaddc(a,b) = (a+b, a+b overflowed ? 1 : 0)";
744-
// TODO: This `let intrinsics = ...` line may be uncommented when
745-
// https://github.com/llvm/llvm-project/issues/113192 is fixed
746-
// let intrinsics = [IntrinSelect<int_uadd_with_overflow>];
744+
let intrinsics = [IntrinSelect<int_uadd_with_overflow>];
747745
let arguments = [OverloadTy, OverloadTy];
748746
let result = BinaryWithCarryTy;
749747
let overloads = [Overloads<DXIL1_0, [Int32Ty]>];

llvm/lib/Target/DirectX/DXILOpBuilder.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,10 +545,6 @@ StructType *DXILOpBuilder::getResRetType(Type *ElementTy) {
545545
return ::getResRetType(ElementTy);
546546
}
547547

548-
StructType *DXILOpBuilder::getBinaryWithCarryType(LLVMContext &Context) {
549-
return ::getBinaryWithCarryType(Context);
550-
}
551-
552548
StructType *DXILOpBuilder::getHandleType() {
553549
return ::getHandleType(IRB.getContext());
554550
}

llvm/lib/Target/DirectX/DXILOpBuilder.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ class DXILOpBuilder {
5050
/// Get a `%dx.types.ResRet` type with the given element type.
5151
StructType *getResRetType(Type *ElementTy);
5252

53-
/// Get the `%dx.types.i32c` type.
54-
StructType *getBinaryWithCarryType(LLVMContext &Context);
55-
5653
/// Get the `%dx.types.Handle` type.
5754
StructType *getHandleType();
5855

llvm/lib/Target/DirectX/DXILOpLowering.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -818,15 +818,6 @@ class OpLowerer {
818818
case Intrinsic::dx_resource_updatecounter:
819819
HasErrors |= lowerUpdateCounter(F);
820820
break;
821-
// TODO: this can be removed when
822-
// https://github.com/llvm/llvm-project/issues/113192 is fixed
823-
case Intrinsic::uadd_with_overflow:
824-
HasErrors |= replaceFunctionWithNamedStructOp(
825-
F, OpCode::UAddc, OpBuilder.getBinaryWithCarryType(M.getContext()),
826-
[&](CallInst *CI, CallInst *Op) {
827-
return replaceAggregateTypeOfCallUsages(CI, Op);
828-
});
829-
break;
830821
case Intrinsic::ctpop:
831822
HasErrors |= lowerCtpopToCountBits(F);
832823
break;

llvm/test/CodeGen/DirectX/UAddc_errors.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ define noundef i16 @uaddc_i16(i16 noundef %a, i16 noundef %b) "hlsl.export" {
1919

2020
; CHECK: error:
2121
; CHECK-SAME: in function uaddc_return
22-
; CHECK-SAME: llvm.uadd.with.overflow.i32 use is not a ExtractValueInst or InsertValueInst
22+
; CHECK-SAME: DXIL ops that return structs may only be used by insert- and extractvalue
2323

2424
define noundef { i32, i1 } @uaddc_return(i32 noundef %a, i32 noundef %b) "hlsl.export" {
2525
%uaddc = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)

0 commit comments

Comments
 (0)