Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,13 +815,15 @@ void CodeGenModule::Release() {
llvm::MDString::get(Ctx, CodeGenOpts.MemoryProfileOutput));
}

if ((LangOpts.CUDAIsDevice || LangOpts.isSYCL()) && getTriple().isNVPTX()) {
if ((LangOpts.CUDAIsDevice || LangOpts.SYCLIsDevice) && getTriple().isNVPTX()) {
// Indicate whether __nvvm_reflect should be configured to flush denormal
// floating point values to 0. (This corresponds to its "__CUDA_FTZ"
// property.)
getModule().addModuleFlag(llvm::Module::Override, "nvvm-reflect-ftz",
CodeGenOpts.FP32DenormalMode.Output !=
llvm::DenormalMode::IEEE);
(CodeGenOpts.FP32DenormalMode.Output !=
llvm::DenormalMode::IEEE) ||
(CodeGenOpts.FPDenormalMode.Output !=
llvm::DenormalMode::IEEE));
getModule().addModuleFlag(llvm::Module::Override, "nvvm-reflect-prec-sqrt",
getTarget().getTargetOpts().NVVMCudaPrecSqrt);
}
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3003,6 +3003,12 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
RoundingMathPresent = false;
break;

case options::OPT_fcuda_flush_denormals_to_zero:
case options::OPT_fgpu_flush_denormals_to_zero:
DenormalFPMath = llvm::DenormalMode::getPositiveZero();
DenormalFP32Math = llvm::DenormalMode::getPositiveZero();
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a driver test verifying the expect values when the options are set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdtoguchi Do you prefer a separate test for this, or should I add it to the clang/test/Driver/fp-model.c?


case options::OPT_fdenormal_fp_math_EQ:
DenormalFPMath = llvm::parseDenormalFPAttribute(A->getValue());
DenormalFP32Math = DenormalFPMath;
Expand Down