[PATCH] D37686: [DAG] Consolidating Instruction->SDNode Flags propagation in one class for better code management.
Hal Finkel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 21 15:17:12 PDT 2017
hfinkel added a comment.
In https://reviews.llvm.org/D37686#878093, @spatel wrote:
> In https://reviews.llvm.org/D37686#877987, @hfinkel wrote:
>
> > While `fast` does imply `nnan`, and `nnan` does propagate backward, and it also implies `arcp`, and `arcp` does not propagate backward. `arcp` applied only to the instruction to which it's attached. In this case, we're allowed to use a reciprocal approximation to the division, and not the sqrt. However, we could argue that using the rsqrt is like doing the sqrt exactly and then just approximating the division. If there are no other users of the sqrt itself, there seems to be little semantic difference.
>
>
> I thought we leaned to the more conservative (less propagating) model in IR. Not sure if that would be different here in the DAG or if rsqrt is a special case.
It's a special case in that it's our only combined reciprocal operation.
> Either way, it doesn't affect the logic at node creation time?
I don't think that it needs to do so.
> Here's a sqrt multi-use case to think about:
>
> define float @multiuse_strict_sqrt(float %x, i1 %cmp) {
> %y = call float @llvm.sqrt.f32(float %x)
> %z = fdiv fast float 1.0, %y
> br i1 %cmp, label %t, label %f
>
> t:
> ret float %z
> f:
> %add = fadd float %y, 1.0
> ret float %add
> }
>
>
> Should this be:
>
> ## BB#0:
> sqrtss %xmm0, %xmm0 <--- shared sqrt op because sqrt is treated as strict
> testb $1, %dil
> je LBB0_2
> ## BB#1: ## %t
> movss LCPI0_0(%rip), %xmm1
> divss %xmm0, %xmm1
> movaps %xmm1, %xmm0
> retq
> LBB0_2: ## %f
> addss LCPI0_0(%rip), %xmm0
> retq
>
This is one valid option. The divss could also be a rcpss (+mul) if we'd like.
> Or:
>
> ## BB#0:
> testb $1, %dil
> je LBB0_2
> ## BB#1: ## %t
> vrsqrtss %xmm0, %xmm0, %xmm1 <--- fast sqrt is assumed part of fast div
> vmulss %xmm1, %xmm0, %xmm0
> vmulss %xmm1, %xmm0, %xmm0
> vaddss LCPI0_0(%rip), %xmm0, %xmm0
> vmulss LCPI0_1(%rip), %xmm1, %xmm1
> vmulss %xmm0, %xmm1, %xmm0
> retq
> LBB0_2: ## %f
> vsqrtss %xmm0, %xmm0, %xmm0 <--- strict sqrt only applies on this path
> vaddss LCPI0_2(%rip), %xmm0, %xmm0
> retq
>
This is another valid option. Either of these seem allowable.
https://reviews.llvm.org/D37686
More information about the llvm-commits
mailing list