[Mesa-dev] [PATCH 05/15] ac: revert new LLVM 7.0 behavior for fdiv
Connor Abbott
cwabbott0 at gmail.com
Mon Oct 29 10:50:22 UTC 2018
ctx->f32_1 probably needs to be replaced by the appropriately-sized
float, like LLVMConstReal(1., ...)
On Mon, Oct 29, 2018 at 11:45 AM Timothy Arceri <tarceri at itsqueeze.com> wrote:
>
> Hi Marek,
>
> It's late and I haven't dug into this any further but this patch causes
> a whole bunch of f64 piglit tests to fail for the radeonsi nir backend.
>
> e.g.
>
> ./bin/shader_runner
> generated_tests/spec/glsl-4.00/execution/built-in-functions/fs-inverse-dmat2.shader_test
> -auto -fbo
>
>
> LLVM ERROR: Cannot select: 0x7fbc48075aa8: f64 = bitcast 0x7fbc48077730
> 0x7fbc48077730: f32 = RCP 0x7fbc4806e788
> 0x7fbc4806e788: f64 = fadd nsz 0x7fbc480757d0, 0x7fbc48075a40
> 0x7fbc480757d0: f64 = fmul nsz 0x7fbc4806f0e0, 0x7fbc4806f420
> 0x7fbc4806f0e0: f64 = bitcast 0x7fbc4806f078
>
> On 30/8/18 6:13 am, Marek Olšák wrote:
> > From: Marek Olšák <marek.olsak at amd.com>
> >
> > Cc: 18.1 18.2 <mesa-stable at lists.freedesktop.org>
> > ---
> > src/amd/common/ac_llvm_build.c | 9 ++++++++-
> > 1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
> > index c741a1ab62d..629cd2a7527 100644
> > --- a/src/amd/common/ac_llvm_build.c
> > +++ b/src/amd/common/ac_llvm_build.c
> > @@ -554,21 +554,28 @@ LLVMValueRef ac_build_expand_to_vec4(struct ac_llvm_context *ctx,
> > chan[num_channels++] = LLVMGetUndef(elemtype);
> >
> > return ac_build_gather_values(ctx, chan, 4);
> > }
> >
> > LLVMValueRef
> > ac_build_fdiv(struct ac_llvm_context *ctx,
> > LLVMValueRef num,
> > LLVMValueRef den)
> > {
> > - LLVMValueRef ret = LLVMBuildFDiv(ctx->builder, num, den, "");
> > + /* If we do (num / den), LLVM >= 7.0 does:
> > + * return num * v_rcp_f32(den * (fabs(den) > 0x1.0p+96f ? 0x1.0p-32f : 1.0f));
> > + *
> > + * If we do (num * (1 / den)), LLVM does:
> > + * return num * v_rcp_f32(den);
> > + */
> > + LLVMValueRef rcp = LLVMBuildFDiv(ctx->builder, ctx->f32_1, den, "");
> > + LLVMValueRef ret = LLVMBuildFMul(ctx->builder, num, rcp, "");
> >
> > /* Use v_rcp_f32 instead of precise division. */
> > if (!LLVMIsConstant(ret))
> > LLVMSetMetadata(ret, ctx->fpmath_md_kind, ctx->fpmath_md_2p5_ulp);
> > return ret;
> > }
> >
> > /* Coordinates for cube map selection. sc, tc, and ma are as in Table 8.27
> > * of the OpenGL 4.5 (Compatibility Profile) specification, except ma is
> > * already multiplied by two. id is the cube face number.
> >
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list