Skip to content

Commit e7a7b5c

Browse files
authored
[AMD] Use uint32 for mask value (#7618)
This conversion can lead to an overflow when subtracting 1 when the signed bit is set. Change to uint32. This is caught when running Conversion/amd/fp_to_fp.mlir with asan
1 parent c6abb22 commit e7a7b5c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

third_party/amd/lib/TritonAMDGPUToLLVM/ElementwiseOpToLLVM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,12 @@ static Value downcastToFp8_RTNE_oneValue(Location loc,
429429

430430
// Get sign and absolute value
431431
Value intVal = b.bitcast(v, srcIntType);
432-
int32_t signMask = 1 << (srcWidth - 1);
432+
uint32_t signMask = 1 << (srcWidth - 1);
433433
Value sign =
434434
b.trunc(i8_ty, b.lshr(b.and_(intVal, srcFpInfo.toLLVMIntValue(signMask)),
435435
srcFpInfo.toLLVMIntValue(srcWidth - 8)));
436436

437-
int32_t absoluteMask = signMask - 1;
437+
uint32_t absoluteMask = signMask - 1;
438438
intVal = b.and_(intVal, srcFpInfo.toLLVMIntValue(absoluteMask));
439439

440440
// Rounding to nearest even

0 commit comments

Comments
 (0)