Skip to content

Commit

Permalink
[Autobackout][FunctionalRegression]Revert of change: 5089830: Removei…
Browse files Browse the repository at this point in the history
…ng dead code

Couldn't produce a test to hit removed code. The maximum (power of 2) value you can store in any iXX variable is 2^XX-1. The 2^XX can't fit into iXX
  • Loading branch information
sys-igc authored and igcbot committed Sep 20, 2024
1 parent 2f01e0a commit e22d8fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
7 changes: 5 additions & 2 deletions IGC/Compiler/Optimizer/IntDivConstantReduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,11 @@ struct IntDivConstantReduction : public FunctionPass
int shiftAmt = divisor.logBase2();
Value *result;
if (isMod) {
// X % 2^K = (X & ((1<<K)-1))
result = B.CreateAnd(dividend, ((1ull << shiftAmt)-1));
if (shiftAmt == bitSize) { // X % MAX_VAL = X
result = dividend;
} else { // X % 2^K = (X & ((1<<K)-1))
result = B.CreateAnd(dividend, ((1ull << shiftAmt)-1));
}
} else {
result = B.CreateLShr(dividend, shiftAmt);
}
Expand Down
11 changes: 0 additions & 11 deletions IGC/Compiler/tests/IntDivConstantReduction/basic.ll
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,6 @@ define spir_kernel void @test_sdiv_max(i32 %src1) {
ret void
}

define spir_kernel void @test_rem_pow_of_2(i32 %src1) {
; CHECK-LABEL: @test_rem_pow_of_2(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[SRC1:%.*]], 2147483647
; CHECK-NEXT: call void @use.i32(i32 [[TMP1]])
; CHECK-NEXT: ret void
;
%1 = urem i32 %src1, 2147483648 ; <- 2^31
call void @use.i32(i32 %1)
ret void
}

define spir_kernel void @test_udiv_max(i32 %src1) {
; CHECK-LABEL: @test_udiv_max(
; CHECK: [[Q_APPX:%.*]] = call i32 @llvm.genx.GenISA.umulH.i32(i32 %src1, i32 -2147483647)
Expand Down

0 comments on commit e22d8fd

Please sign in to comment.