Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating 64-bit movd after cmpneqsd when targeting 32-bit mode #19433

Closed
zmodem opened this issue Mar 6, 2014 · 3 comments
Closed

Generating 64-bit movd after cmpneqsd when targeting 32-bit mode #19433

zmodem opened this issue Mar 6, 2014 · 3 comments
Assignees
Labels
backend:X86 bugzilla Issues migrated from bugzilla

Comments

@zmodem
Copy link
Collaborator

zmodem commented Mar 6, 2014

Bugzilla Link 19059
Resolution FIXED
Resolved on Mar 11, 2014 10:51
Version trunk
OS Windows NT
Blocks #19261
Attachments Preprocessed input, bitcode repro
CC @topperc,@rnk

Extended Description

To reproduce:

clang -cc1 -triple i386-pc-win32 -mstackrealign -target-cpu pentium4 -fms-extensions -S -o - b.ii

We're miscompiling this statement:

updateAnimations(SMILTime(m_presetStartTime), m_presetStartTime ? true : false);

In Clang's asm printout, we have this:

    movsd   32(%edx), %xmm0
    xorps   %xmm1, %xmm1
    cmpneqsd        %xmm0, %xmm1
    movd    %xmm1, %rsi

Note that the last instruction tries to move xmm1 to a 64-bit register, but we're targeting i386.

Disassembling the object file shows different instructions:

000000AE: F2 0F 10 42 20 movsd xmm0,mmword ptr [edx+20h]
000000B3: 0F 57 C9 xorps xmm1,xmm1
000000B6: F2 0F C2 C8 04 cmpneqsd xmm1,xmm0
000000BB: 66 0F 7E CE movd esi,xmm1

Turns out our 64-bit move to rsi becomes a 32-bit move into esi? But esi is used as base pointer in this function; we have now clobbered it and will crash a few lines down.

The 64-bit move looks like this (this is from "Before Expand ISel Pseudo-instructions"):

%vreg32<def> = FsFLD0SD; FR64:%vreg32
%vreg33<def,tied1> = CMPSDrr %vreg32<tied0>, %vreg31<kill>, 4; FR64:%vreg33,%vreg32,%vreg31
%vreg34<def> = MOVSDto64rr %vreg33<kill>; GR64:%vreg34 FR64:%vreg33

after register allocation, we think we're moving into rsi:

%XMM1<def> = FsFLD0SD
%XMM1<def,tied1> = CMPSDrr %XMM1<tied0>, %XMM0<kill>, 4
%RSI<def> = MOVSDto64rr %XMM1<kill>

There's something strange going on here :)

(This is reduced from WebCore::SMILTimeContainer::begin.)

@zmodem
Copy link
Collaborator Author

zmodem commented Mar 6, 2014

assigned to @zmodem

@topperc
Copy link
Collaborator

topperc commented Mar 6, 2014

Far as I can tell the bug was introduced in r197384. Going to do some more digging to see what happened before that.

@zmodem
Copy link
Collaborator Author

zmodem commented Mar 11, 2014

Fixed in r203581.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

2 participants