Skip to content

Commit 71aee74

Browse files
mshelegoigcbot
authored andcommitted
Change default float controls
By default enable denormals retain and make float to integer conversion use the same rounding mode as FP operations (RTNE)
1 parent b2e7cfd commit 71aee74

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXFloatControl.cpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class GenXFloatControl : public FGPassImplInterface, IDMixin<GenXFloatControl> {
3636

3737
bool getFloatControl(Function *F, uint32_t *Val);
3838

39-
Value *buildCr0Update(Value* V, Instruction *InsertBefore);
39+
Value *buildCr0Update(Value *V, Instruction *InsertBefore);
4040

4141
public:
4242
void releaseMemory() {}
@@ -72,14 +72,21 @@ ModulePass *llvm::createGenXFloatControlWrapperPass() {
7272
}
7373

7474
bool GenXFloatControl::runOnFunctionGroup(FunctionGroup &FG) {
75+
// By default retain all denormals, rounding mode - RTNE (both FPU and float
76+
// to integer conversion)
77+
DefaultFloatControl = Bits::DoublePrecisionDenorm |
78+
Bits::SinglePrecisionDenorm |
79+
Bits::HalfPrecisionDenorm | Bits::FPToIntRoundingMode;
80+
7581
// By default allow to specify with the attribute only rounding and denorm
7682
// modes
7783
Mask = Bits::RoundingMode | Bits::DoublePrecisionDenorm |
78-
Bits::SinglePrecisionDenorm | Bits::HalfPrecisionDenorm;
84+
Bits::SinglePrecisionDenorm | Bits::HalfPrecisionDenorm;
7985
const auto *Subtarget = &getAnalysis<TargetPassConfig>()
8086
.getTM<GenXTargetMachine>()
8187
.getGenXSubtarget();
8288
if (Subtarget->hasSystolicDenormControl()) {
89+
DefaultFloatControl |= Bits::SystolicDenorm;
8390
Mask |= Bits::SystolicDenorm;
8491
}
8592

@@ -134,9 +141,9 @@ Value *GenXFloatControl::buildCr0Update(Value *V, Instruction *InsertBefore) {
134141
auto *Or = B.CreateOr(AndOld, AndNew);
135142
auto *WrR = R.createWrRegion(Cr0, Or, "cr0.0.updated", InsertBefore, DL);
136143

137-
B.CreateCall(
138-
vc::getAnyDeclaration(M, GenXIntrinsic::genx_write_predef_reg, {VTy, VTy}),
139-
{Id, WrR});
144+
B.CreateCall(vc::getAnyDeclaration(M, GenXIntrinsic::genx_write_predef_reg,
145+
{VTy, VTy}),
146+
{Id, WrR});
140147

141148
return RdR;
142149
}

IGC/VectorCompiler/test/GenXFloatControl/float_control.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
; CHECK-NEXT: [[VAR1:[^ ]+]] = call <4 x i32> @llvm.genx.read.predef.reg.v4i32.v4i32(i32 14, <4 x i32> undef)
1414
; CHECK-NEXT: [[VAR2:[^ ]+]] = call i32 @llvm.genx.rdregioni.i32.v4i32.i16(<4 x i32> [[VAR1]], i32 0, i32 1, i32 1, i16 0, i32 undef)
1515
; CHECK-NEXT: [[VAR3:[^ ]+]] = and i32 [[VAR2]], -1265
16-
; CHECK-NEXT: [[VAR4:[^ ]+]] = or i32 [[VAR3]], 0
16+
; CHECK-NEXT: [[VAR4:[^ ]+]] = or i32 [[VAR3]], 1216
1717
; CHECK-NEXT: [[VAR5:[^ ]+]] = call <4 x i32> @llvm.genx.wrregioni.v4i32.i32.i16.i1(<4 x i32> [[VAR1]], i32 [[VAR4]], i32 0, i32 1, i32 1, i16 0, i32 undef, i1 true)
1818
; CHECK-NEXT: call <4 x i32> @llvm.genx.write.predef.reg.v4i32.v4i32(i32 14, <4 x i32> [[VAR5]])
1919
define dllexport spir_kernel void @kernel(i32 %arg, i64 %privBase) #0 {

0 commit comments

Comments
 (0)