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

ICE with simd_cast #39720

Closed
rawrafox opened this issue Feb 10, 2017 · 3 comments
Closed

ICE with simd_cast #39720

rawrafox opened this issue Feb 10, 2017 · 3 comments
Labels
A-SIMD Area: SIMD (Single Instruction Multiple Data) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@rawrafox
Copy link

rawrafox commented Feb 10, 2017

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.

@sanxiyn sanxiyn added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 14, 2017
@Aaron1011
Copy link
Member

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.

@Aaron1011
Copy link
Member

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.

@Mark-Simulacrum Mark-Simulacrum added the A-SIMD Area: SIMD (Single Instruction Multiple Data) label Jun 22, 2017
@Mark-Simulacrum
Copy link
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).

@Mark-Simulacrum Mark-Simulacrum added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jun 22, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-SIMD Area: SIMD (Single Instruction Multiple Data) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants