*/
flags.setAllowReciprocal(); /* arcp */
+ /* Allow floating-point contraction (e.g. fusing a multiply
+ * followed by an addition into a fused multiply-and-add).
+ */
+ flags.setAllowContract(); /* contract */
+
llvm::unwrap(builder)->setFastMathFlags(flags);
break;
}
return builder;
}
+/* Return the original state of inexact math. */
+bool ac_disable_inexact_math(LLVMBuilderRef builder)
+{
+ auto *b = llvm::unwrap(builder);
+ llvm::FastMathFlags flags = b->getFastMathFlags();
+
+ if (!flags.allowContract())
+ return false;
+
+ flags.setAllowContract(false);
+ b->setFastMathFlags(flags);
+ return true;
+}
+
+void ac_restore_inexact_math(LLVMBuilderRef builder, bool value)
+{
+ auto *b = llvm::unwrap(builder);
+ llvm::FastMathFlags flags = b->getFastMathFlags();
+
+ if (flags.allowContract() == value)
+ return;
+
+ flags.setAllowContract(value);
+ b->setFastMathFlags(flags);
+}
+
LLVMTargetLibraryInfoRef
ac_create_target_library_info(const char *triple)
{
LLVMBuilderRef ac_create_builder(LLVMContextRef ctx,
enum ac_float_mode float_mode);
+bool ac_disable_inexact_math(LLVMBuilderRef builder);
+void ac_restore_inexact_math(LLVMBuilderRef builder, bool value);
void
ac_llvm_add_target_dep_function_attr(LLVMValueRef F,
unsigned num_components = instr->dest.dest.ssa.num_components;
unsigned src_components;
LLVMTypeRef def_type = get_def_type(ctx, &instr->dest.dest.ssa);
+ bool saved_inexact = false;
+
+ if (instr->exact)
+ saved_inexact = ac_disable_inexact_math(ctx->ac.builder);
assert(nir_op_infos[instr->op].num_inputs <= ARRAY_SIZE(src));
switch (instr->op) {
result = ac_to_integer_or_pointer(&ctx->ac, result);
ctx->ssa_defs[instr->dest.dest.ssa.index] = result;
}
+
+ if (instr->exact)
+ ac_restore_inexact_math(ctx->ac.builder, saved_inexact);
}
static void visit_load_const(struct ac_nir_context *ctx,