Skip to content

CMM compiles with 8.0.2, fails with git HEAD

I'm trying to implement Float <-> Word32 bit casts (Double <-> Word64 works fine) in CMM using:

stg_word32ToFloatzh(I32 w)
{
    F_ f;
    P_ ptr;

    STK_CHK_GEN_N (FLOAT_STACK_WDS);

    reserve FLOAT_STACK_WDS = ptr {
        I32[ptr] = w;
        f = F_[ptr];
    }

    return (f);
}

stg_floatToWord32zh(F_ f)
{
    I32 w;
    P_ ptr;

    STK_CHK_GEN_N (FLOAT_STACK_WDS);

    reserve FLOAT_STACK_WDS = ptr {
        I32[ptr] = f;
        w = I32[ptr];
    }

    return (w);
}

This compiles correctly and passes all tests with ghc 8.0.2, but compiling the above CMM with git HEAD (currently 1e58efb1) results in:

Cmm lint error:
  in basic block cq
    in assignment: 
      _cj::I32 = R1;
      Reg ty: I32
      Rhs ty: I64
Program was:
  {offset
    cq: // global
        _cj::I32 = R1;
        //tick src<rts/CastFloatWord.cmm:(49,1)-(61,1)>
        goto cm;
    cm: // global
        if ((old + 0) - 8 / 8 < SpLim) (likely: False) goto co; else goto cp;
    co: // global
        I64[(young<cn> + 8)] = cn;
        call stg_gc_noregs() returns to cn, args: 8, res: 8, upd: 8;
    cn: // global
        goto cm;
    cp: // global
        _cl::P64 = (old + 16);
        //tick src<rts/CastFloatWord.cmm:(55,29)-(58,5)>
        I32[_cl::P64] = _cj::I32;
        _ck::F32 = F32[_cl::P64];
        F1 = _ck::F32;
        call (P64[(old + 8)])(F1) args: 8, res: 0, upd: 8;
  }

ghc 8.0.2 is accepts this code and gives the correct results, so I can only assume that git HEAD is incorrect.

Trac metadata
Trac field Value
Version 8.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information