Skip to content

Instruction selection failure: f64->f32 truncation into a store #252

@xdoardo

Description

@xdoardo

Compiling the following Rust code

let x1p_126 = f64::from_bits(0x3810000000000000); // 0x1p-126 == 2^-126
unsafe { ::core::ptr::read_volatile(&((x1p_126 / x) as f32)) };

produces this instruction selection failure:

rustc-LLVM ERROR: Cannot select: 0x1498f16e0: ch = store<(store (s32) into %ir.2, addrspace 200), trunc to f32> 0x1498f3c00, 0x149906980, FrameIndex:c64<0>, undef:c64, library/compiler-builtins/compiler-builtins/src/math/../../../libm/src/math/tgamma.rs:172:25
  0x149906980: f64,ch,glue = CopyFromReg 0x1499069f0, Register:f64 $c10, 0x1499069f0:1, library/compiler-builtins/compiler-builtins/src/math/../../../libm/src/math/tgamma.rs:172:25
    0x1499069f0: ch,glue = callseq_end 0x149905470, TargetConstant:i32<0>, TargetConstant:i32<0>, 0x149905470:1, library/compiler-builtins/compiler-builtins/src/math/../../../libm/src/math/tgamma.rs:172:25
      0x149905470: ch,glue = RISCVISD::CAP_LIB_CALL 0x149906670, TargetExternalSymbol:c64'__divdf3' [TF=21], Register:f64 $c10, Register:f64 $c11, RegisterMask:Untyped, 0x149906670:1, library/compiler-builtins/compiler-builtins/src/math/../../../libm/src/math/tgamma.rs:172:25
        0x149906670: ch,glue = CopyToReg 0x1499066e0, Register:f64 $c11, 0x1498f40d0, 0x1499066e0:1, library/compiler-builtins/compiler-builtins/src/math/../../../libm/src/math/tgamma.rs:172:25
          0x1498f40d0: f64,ch = CopyFromReg 0x138e59238, Register:f64 %44, library/compiler-builtins/compiler-builtins/src/math/../../../libm/src/math/tgamma.rs:172:25
          0x1499066e0: ch,glue = CopyToReg 0x149905160, Register:f64 $c10, 0x149906fa0, library/compiler-builtins/compiler-builtins/src/math/../../../libm/src/math/tgamma.rs:172:25
            0x149906fa0: f64 = bitcast 0x149907010
              0x149907010: c64 = llvm.cheri.cap.high.set TargetConstant:i32<38>, 0x149906e50, Constant:i32<940572672>
                0x149906e50: c64 = INSERT_SUBREG undef:f64, Constant:i32<0>, TargetConstant:i32<4>

Culprit .ll module disguised as a .txt to make GH happy:
compiler_builtins-410dc471d12f38f0.compiler_builtins.c30927b5eaf23c96-cgu.022.rcgu.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions