ac/llvm: add AC_FLOAT_MODE_ROUND_TO_ZERO
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 14 Oct 2019 13:36:37 +0000 (15:36 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 18 Oct 2019 14:55:51 +0000 (16:55 +0200)
Because some instructions will be optimized by the backend compiler,
the driver has to manually flush to zero to keep the result exact.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/llvm/ac_llvm_build.c
src/amd/llvm/ac_llvm_build.h
src/amd/llvm/ac_llvm_helper.cpp
src/amd/llvm/ac_llvm_util.h

index 87adf2b44324549d941e72739d0f9bbcbc271463..d9ece7049c75bf81cbdce6d6992ba5f41d70c7dd 100644 (file)
@@ -73,6 +73,7 @@ ac_llvm_context_init(struct ac_llvm_context *ctx,
        ctx->family = family;
        ctx->wave_size = wave_size;
        ctx->ballot_mask_bits = ballot_mask_bits;
+       ctx->float_mode = float_mode;
        ctx->module = ac_create_module(wave_size == 32 ? compiler->tm_wave32
                                                       : compiler->tm,
                                       ctx->context);
index a67e1d49d4d48faa4c63afbe5af17027cb80ca58..8cd15cbe99ff607ae058ddc2bf0ff918c09a6500 100644 (file)
@@ -120,6 +120,8 @@ struct ac_llvm_context {
        unsigned wave_size;
        unsigned ballot_mask_bits;
 
+       unsigned float_mode;
+
        LLVMValueRef lds;
 };
 
index b7a72ee3fdd3f70055456942d7667fc3f3291ac5..7f3ff71fd9c952d133ff5588736b5f76c99b5b33 100644 (file)
@@ -82,6 +82,7 @@ LLVMBuilderRef ac_create_builder(LLVMContextRef ctx,
 
        switch (float_mode) {
        case AC_FLOAT_MODE_DEFAULT:
+       case AC_FLOAT_MODE_DENORM_FLUSH_TO_ZERO:
                break;
        case AC_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH:
                flags.setNoSignedZeros();
index 60c9a17e447d77b1340aa4808c6f16c69c203bf1..a864f524fbe43282580a4c1d20fff1f3c978a237 100644 (file)
@@ -73,6 +73,7 @@ enum ac_float_mode {
        AC_FLOAT_MODE_DEFAULT,
        AC_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH,
        AC_FLOAT_MODE_UNSAFE_FP_MATH,
+       AC_FLOAT_MODE_DENORM_FLUSH_TO_ZERO,
 };
 
 /* Per-thread persistent LLVM objects. */