llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

SQRTSS and similar scalar SSE insns are not accurately modelled

Open darkbuck opened this issue 14 years ago • 10 comments

Bugzilla Link 14221
Resolution FIXED
Resolved on Jun 18, 2015 18:35
Version trunk
OS Linux
Blocks llvm/llvm-bugzilla-archive#22206
CC @rotateright

Extended Description

Scalar SSE instructions, such as SQRTSS, should be model as binary insns with the one input tied to the output and the other is the regular numeric input source. This's exactly the model of AVX variants.

darkbuck avatar Oct 31 '12 01:10 darkbuck

mentioned in issue llvm/llvm-bugzilla-archive#23349

ahmedbougacha avatar Nov 26 '21 20:11 ahmedbougacha

mentioned in issue llvm/llvm-bugzilla-archive#22206

rotateright avatar Nov 26 '21 20:11 rotateright

mentioned in issue llvm/llvm-bugzilla-archive#21507

rotateright avatar Nov 26 '21 19:11 rotateright

sqrtsd patch committed here: http://llvm.org/viewvc/llvm-project?view=revision&revision=227111

As noted in the review for this patch (http://reviews.llvm.org/D6885), by tying the source and dest regs, we've introduced a small SSE perf regression in the case where we need to use the original operand and the result.

rotateright avatar Jan 26 '15 21:01 rotateright

sqrtss patch committed here: http://llvm.org/viewvc/llvm-project?view=revision&revision=224624

I'll work on the sqrtsd patch next unless someone gets to it before me.

rotateright avatar Dec 20 '14 00:12 rotateright

For the record, we are producing wrong code without this patch.

It wasn't immediately obvious to me how this happens, but in the sqrt test case in the patch, we will generate this SSE code:

sqrtss	%xmm0, %xmm1    <--- high elements of %xmm1 are undefined
xorps	%xmm0, %xmm0
cvtss2sd	%xmm1, %xmm0 <--- this is ok; low element def'd by sqrtss
shufps	$-27, %xmm1, %xmm1      ## xmm1 = xmm1[1,1,2,3]
cvtss2sd	%xmm1, %xmm1  <--- oops: undef value
jmp	_callee

rotateright avatar Nov 20 '14 18:11 rotateright

Patch for sqrtss submitted for review: http://reviews.llvm.org/D6330

rotateright avatar Nov 20 '14 01:11 rotateright

Fixed RSQRTss & RCPss in r167064. SQRTss and SQRTsd also needs to be fixed.

llvmbot avatar Nov 02 '12 21:11 llvmbot

According to Manman, it's still incomplete. BE still needs more fixed.

darkbuck avatar Nov 01 '12 23:11 darkbuck

This was fixed by 167064, no?

llvmbot avatar Nov 01 '12 23:11 llvmbot