[PATCH] D37686: [DAG] Consolidating Instruction->SDNode Flags propagation in one class for better code management.
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 21 13:47:13 PDT 2017
spatel added a comment.
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. Either way, it doesn't affect the logic at node creation time?
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
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
https://reviews.llvm.org/D37686
More information about the llvm-commits
mailing list