Skip to content

Commit 5572ee3

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: c3870c8: Replace EATOMIC_IADD with EATOMIC_INC and EATOMIC_DEC when
immediate is 1 or -1 as increment or decrement In cases a shader is doing typed atomics with typed, or untyped atomics with ugm, or untyped atomics with slm and just increment or decrement atomic operation using an immediate as -1 and 1, we can use EATOMIC_INC(2) or EATOMIC_DEC(3) to replace EATOMIC_IADD.
1 parent 69e5a51 commit 5572ee3

File tree

3 files changed

+1
-192
lines changed

3 files changed

+1
-192
lines changed

IGC/Compiler/CustomSafeOptPass.cpp

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*========================== begin_copyright_notice ============================
22
3-
Copyright (C) 2017-2025 Intel Corporation
3+
Copyright (C) 2017-2024 Intel Corporation
44
55
SPDX-License-Identifier: MIT
66
@@ -472,68 +472,6 @@ static bool isTruncInvariant(unsigned Opcode) {
472472
}
473473
}
474474

475-
// clang-format off
476-
// In AtomicTyped, convert EATOMIC_IADD(0) to EATOMIC_INC(2) and EATOMIC_DEC(3) when value of 1 is used as increment or -1 as decrement
477-
// From:
478-
// %7 = call i32 @llvm.genx.GenISA.intatomictyped.i32.p2490368__Buffer_Typed_DIM_Resource(%__Buffer_Typed_DIM_Resource addrspace(2490368)* %u01, i32 %ThreadID_X, i32 undef, i32 undef, i32 1, i32 0)
479-
// %8 = call i32 @llvm.genx.GenISA.intatomictyped.i32.p2490368__Buffer_Typed_DIM_Resource(%__Buffer_Typed_DIM_Resource addrspace(2490368)* %u01, i32 %ThreadID_X, i32 undef, i32 undef, i32 -1, i32 0)
480-
// To:
481-
// %7 = call i32 @llvm.genx.GenISA.intatomictyped.i32.p2490368__Buffer_Typed_DIM_Resource(%__Buffer_Typed_DIM_Resource addrspace(2490368)* %u01, i32 %ThreadID_X, i32 undef, i32 undef, i32 1, i32 2)
482-
// %8 = call i32 @llvm.genx.GenISA.intatomictyped.i32.p2490368__Buffer_Typed_DIM_Resource(%__Buffer_Typed_DIM_Resource addrspace(2490368)* %u01, i32 %ThreadID_X, i32 undef, i32 undef, i32 -1, i32 3)
483-
// clang-format on
484-
void CustomSafeOptPass::visitIntAtomicTyped(CallInst *I) {
485-
486-
GenIntrinsicInst *instr = dyn_cast<GenIntrinsicInst>(I);
487-
488-
// for immediate 1 or -1
489-
if (auto *constInt1 = llvm::dyn_cast<llvm::ConstantInt>(instr->getOperand(4))) {
490-
// for atomic_iadd
491-
if (auto *constInt2 = llvm::dyn_cast<llvm::ConstantInt>(instr->getOperand(5))) {
492-
if (AtomicOp::EATOMIC_IADD == constInt2->getZExtValue()) {
493-
if (constInt1->getSExtValue() == 1) {
494-
instr->setOperand(5, llvm::ConstantInt::get(instr->getOperand(5)->getType(), AtomicOp::EATOMIC_INC));
495-
} else if (constInt1->getSExtValue() == -1) {
496-
instr->setOperand(5, llvm::ConstantInt::get(instr->getOperand(5)->getType(), AtomicOp::EATOMIC_DEC));
497-
}
498-
}
499-
}
500-
}
501-
}
502-
503-
// clang-format off
504-
// In AtomicRaw or AtomicRawA64, convert EATOMIC_IADD(0) to EATOMIC_INC(2) and EATOMIC_DEC(3) when value of 1 is used as increment or -1 as decrement
505-
// From:
506-
// %10 = call i32 @llvm.genx.GenISA.intatomicraw.i32.p2490369v4f32(<4 x float> addrspace(2490369)* %u0, i32 %9, i32 1, i32 0)
507-
// %11 = call i32 @llvm.genx.GenISA.intatomicraw.i32.p2490369v4f32(<4 x float> addrspace(2490369)* %u0, i32 %9, i32 -1, i32 0)
508-
// or
509-
// %13 = call i32 @llvm.genx.GenISA.intatomicrawA64.i32.p3i32.p3i32(i32 addrspace(3)* %12, i32 addrspace(3)* %12, i32 1, i32 0)
510-
// %14 = call i32 @llvm.genx.GenISA.intatomicrawA64.i32.p3i32.p3i32(i32 addrspace(3)* %12, i32 addrspace(3)* %12, i32 -1, i32 0)
511-
// To:
512-
// %10 = call i32 @llvm.genx.GenISA.intatomicraw.i32.p2490369v4f32(<4 x float> addrspace(2490369)* %u0, i32 %9, i32 1, i32 2)
513-
// %11 = call i32 @llvm.genx.GenISA.intatomicraw.i32.p2490369v4f32(<4 x float> addrspace(2490369)* %u0, i32 %9, i32 -1, i32 3)
514-
// or
515-
// %13 = call i32 @llvm.genx.GenISA.intatomicrawA64.i32.p3i32.p3i32(i32 addrspace(3)* %12, i32 addrspace(3)* %12, i32 1, i32 2)
516-
// %14 = call i32 @llvm.genx.GenISA.intatomicrawA64.i32.p3i32.p3i32(i32 addrspace(3)* %12, i32 addrspace(3)* %12, i32 -1, i32 3)
517-
// clang-format on
518-
void CustomSafeOptPass::visitIntAtomicRawOrRawA64(CallInst *I) {
519-
520-
GenIntrinsicInst *instr = dyn_cast<GenIntrinsicInst>(I);
521-
522-
// for immediate 1 or -1
523-
if (auto *constInt1 = llvm::dyn_cast<llvm::ConstantInt>(instr->getOperand(2))) {
524-
// for atomic_iadd
525-
if (auto *constInt2 = llvm::dyn_cast<llvm::ConstantInt>(instr->getOperand(3))) {
526-
if (AtomicOp::EATOMIC_IADD == constInt2->getZExtValue()) {
527-
if (constInt1->getSExtValue() == 1) {
528-
instr->setOperand(3, llvm::ConstantInt::get(instr->getOperand(3)->getType(), AtomicOp::EATOMIC_INC));
529-
} else if (constInt1->getSExtValue() == -1) {
530-
instr->setOperand(3, llvm::ConstantInt::get(instr->getOperand(3)->getType(), AtomicOp::EATOMIC_DEC));
531-
}
532-
}
533-
}
534-
}
535-
}
536-
537475
// Searches for following pattern:
538476
// %mul = mul i64 %conv, %conv2
539477
// %conv3 = and i64 %mul, 0xFFFFFFFF
@@ -900,17 +838,6 @@ void CustomSafeOptPass::visitCallInst(CallInst &C) {
900838
break;
901839
}
902840

903-
case GenISAIntrinsic::GenISA_intatomictyped: {
904-
visitIntAtomicTyped(inst);
905-
break;
906-
}
907-
908-
case GenISAIntrinsic::GenISA_intatomicraw:
909-
case GenISAIntrinsic::GenISA_intatomicrawA64: {
910-
visitIntAtomicRawOrRawA64(inst);
911-
break;
912-
}
913-
914841
default:
915842
break;
916843
}

IGC/Compiler/CustomSafeOptPass.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ class CustomSafeOptPass : public llvm::FunctionPass, public llvm::InstVisitor<Cu
7272
void visitSelectInst(llvm::SelectInst &S);
7373
void mergeDotAddToDp4a(llvm::CallInst *I);
7474
void visitTruncInst(llvm::TruncInst &I);
75-
void visitIntAtomicTyped(llvm::CallInst *I);
76-
void visitIntAtomicRawOrRawA64(llvm::CallInst *I);
7775

7876
//
7977
// IEEE Floating point arithmetic is not associative. Any pattern

IGC/Compiler/tests/CustomSafeOptPass/eatomic_iadd_to_inc_dec.ll

Lines changed: 0 additions & 116 deletions
This file was deleted.

0 commit comments

Comments
 (0)