diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-06-06 06:32:50 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-06-06 06:32:50 +0000 |
commit | 30e71eb61bcbcc31214617996dc4927d5c3169de (patch) | |
tree | 405cff99af101ca788cbd3a880997c4653d7a488 | |
parent | b4a921af0577a8011be6a314aa146d3d462b32c4 (diff) |
Avoid crashing on a variable-index insertelement with element type i16.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72991 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/X86ISelLowering.cpp | 2 | ||||
-rw-r--r-- | test/CodeGen/X86/2009-06-05-VariableIndexInsert.ll | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index ec6a5bad5b..ef60ff5e09 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -4272,7 +4272,7 @@ X86TargetLowering::LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) { SDValue N1 = Op.getOperand(1); SDValue N2 = Op.getOperand(2); - if (EVT.getSizeInBits() == 16) { + if (EVT.getSizeInBits() == 16 && isa<ConstantSDNode>(N2)) { // Transform it so it match pinsrw which expects a 16-bit value in a GR32 // as its second argument. if (N1.getValueType() != MVT::i32) diff --git a/test/CodeGen/X86/2009-06-05-VariableIndexInsert.ll b/test/CodeGen/X86/2009-06-05-VariableIndexInsert.ll new file mode 100644 index 0000000000..2e3f195ff9 --- /dev/null +++ b/test/CodeGen/X86/2009-06-05-VariableIndexInsert.ll @@ -0,0 +1,11 @@ +; RUN: llvm-as < %s | llc + +define <2 x i64> @_mm_insert_epi16(<2 x i64> %a, i32 %b, i32 %imm) nounwind readnone { +entry: + %conv = bitcast <2 x i64> %a to <8 x i16> ; <<8 x i16>> [#uses=1] + %conv2 = trunc i32 %b to i16 ; <i16> [#uses=1] + %and = and i32 %imm, 7 ; <i32> [#uses=1] + %vecins = insertelement <8 x i16> %conv, i16 %conv2, i32 %and ; <<8 x i16>> [#uses=1] + %conv6 = bitcast <8 x i16> %vecins to <2 x i64> ; <<2 x i64>> [#uses=1] + ret <2 x i64> %conv6 +} |