Skip to content

ICE with simd_cast #39720

Closed
Closed

Description

@rawrafox

When casting from i8x3 -> i16x3 there's an ICE on rustc 1.17.0-nightly (24a70eb59 2017-02-09)

PromoteIntegerResult #0: t35: v4i16 = sign_extend_vector_inreg t34

Do not know how to promote this operator!
UNREACHABLE executed at /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:51!

Test case: https://gist.github.com/rawrasaur/27a3e624e5a6e071bc4e9059795fd97b

It seems to trigger when the width is 3, the source is not a float, and in size is smaller than the out size. Clang handles this case fine in its __builtin_convertvector.

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on Feb 14, 2017
  2. Aaron1011 commented on Apr 23, 2017

    @Aaron1011
    Contributor

    This appears to be an LLVM bug. The following reduced LLVM IR file triggers the crash on both Rust's LLVM fork, and LLVM 3.9. It appears to be fixed on LLVM 4.0

    define i64 @main(i64, i8**) unnamed_addr {
    start:
    
      %veci8 = alloca <3 x i8>
      %veci16 = alloca <3 x i16>
    
      %2 = load <3 x i8>, <3 x i8>* %veci8
      %3 = sext <3 x i8> %2 to <3 x i16>
      store <3 x i16> %3, <3 x i16>* %veci16
    
      ret i64 0
    }
    

    From what I've discovered so far, the bug is related to LLVM's x86 platform code performing this optimization on the LLVM selection DAG:

    load, sign_extend -> load, concat_vectors, sign_extend_vector_inreg. The relevant code can be found at src/llvm/lib/Target/X86/X86ISelLowering.cpp in the function combineToExtendVectorInReg (starts at line 30090). Github unfortunately disallows linking lines in the file, as it's over 30K (!) lines.

    I'm going to investigate this further, and see if I can determine what was changed in LLVM 4.0 to fix this.

  3. Aaron1011 commented on Apr 23, 2017

    @Aaron1011
    Contributor

    It turns out that this bug was already fixed in LLVM: See https://reviews.llvm.org/D25790 and https://reviews.llvm.org/D25268. The rust-llvm-2016-10-29 branch of Rust's LLVM fork doesn't include these fixes, however, the rust-llvm-2017-04-13.

    I don't know exactly what the Rust team's procedure is for updating LLVM, but this issue should be resolved when the rust-llvm-2017-04-13 branch is in use.

  4. Mark-Simulacrum commented on Jun 22, 2017

    @Mark-Simulacrum
    Member

    Cannot reproduce today (we are on llvm 4.0 now), marking E-needstest. I believe this'll need a run-pass test since compile-fail with rustc_error I believe doesn't run LLVM (which is where the problem occurs, presumably).

  5. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Jun 22, 2017
  6. added a commit that references this issue on Jul 26, 2017
    9f4450b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-SIMDArea: SIMD (Single Instruction Multiple Data)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions