[llvm] [SLP] Fix crash on extractelement with out-of-bounds index.....Fixes … (PR #176918)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 25 10:33:44 PST 2026


https://github.com/Soumik15630 updated https://github.com/llvm/llvm-project/pull/176918

>From 46ecbe0d4c347001df3e0251b8d3a37a3f12e89e Mon Sep 17 00:00:00 2001
From: Soumik15630m <soumik15630m at gmail.com>
Date: Tue, 20 Jan 2026 18:15:37 +0530
Subject: [PATCH 01/12] [SLP] Fix crash on extractelement with out-of-bounds
 index.....Fixes #176780. The cose modeling logic was attempting to set a bit
 in APInt for an out-of-bounds index, causing an assertion failure. This patch
 ignores OOB indices as they produce poison- which is already handled.

---
 llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 762b394f8ea8a..8125eb27a2e98 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -15042,7 +15042,14 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
       }
       if (DemandedElts.isZero())
         DemandedElts = APInt::getZero(getNumElements(SrcVecTy));
-      DemandedElts.setBit(*getExtractIndex(I));
+      unsigned ExtIdx = *getExtractIndex(I);
+      //Out-of-bounds extractelement produces poison.So it do no corresponds to a concrete vector lane,
+      // so instead of treating it as an invalid pattern we can avoid marking any demanded element
+      if (ExtIdx  < DemandedElts.getBitWidth())
+      {
+        DemandedElts.setBit(ExtIdx);
+      }
+      // DemandedElts.setBit(*getExtractIndex(I));
       return InstructionCost(TTI::TCC_Free);
     };
     auto GetVectorCost = [&, &TTI = *TTI](InstructionCost CommonCost) {

>From e95278fdcfa6991e1c1e7bbea085924e63eeac6a Mon Sep 17 00:00:00 2001
From: Soumik15630m <soumik15630m at gmail.com>
Date: Tue, 20 Jan 2026 18:29:49 +0530
Subject: [PATCH 02/12] [SLP] Fix crash on extractelement with out-of-bounds
 index....Added the regression test for out-of-bound-extract

---
 .../X86/crash-on-out-of-bound-extract.ll      | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 llvm/test/Transforms/SLPVectorizer/X86/crash-on-out-of-bound-extract.ll

diff --git a/llvm/test/Transforms/SLPVectorizer/X86/crash-on-out-of-bound-extract.ll b/llvm/test/Transforms/SLPVectorizer/X86/crash-on-out-of-bound-extract.ll
new file mode 100644
index 0000000000000..d971f537f6330
--- /dev/null
+++ b/llvm/test/Transforms/SLPVectorizer/X86/crash-on-out-of-bound-extract.ll
@@ -0,0 +1,25 @@
+; RUN: opt -passes=slp-vectorizer -S < %s | FileCheck %s
+
+define <4 x i32> @test(<4 x i32> %A){
+; CHECK-LABEL: @test(
+; CHECK-NEXT: entry:
+; CHECK-NEXT:   [[TMP0:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> poison, <4 x i32> <i32 0, i32 1, i32 3, i32 1>
+; CHECK-NEXT:   [[TMP1:%.*]] = sdiv <4 x i32> [[A]], [[TMP0]]
+; CHECK-NEXT:   ret <4 x i32> [[TMP1]]
+;
+entry:
+    %e0 = extractelement <4 x i32> %A, i64 0
+    %e1 = extractelement <4 x i32> %A, i64 1
+    %e2 = extractelement <4 x i32> %A, i64 2
+    %e3 = extractelement <4 x i32> %A, i64 3
+    %oob = extractelement <4 x i32> %A, i64 4
+    %d0 = sdiv i32 %e0, %e0
+    %d1 = sdiv i32 %oob, %e1
+    %d2 = sdiv i32 %e2, %e3
+    %d3 = sdiv i32 %oob, %e1
+    %v0 = insertelement <4 x i32> poison, i32 %d0, i64 0
+    %v1 = insertelement <4 x i32> %v0, i32 %d1, i64 1
+    %v2 = insertelement <4 x i32> %v1, i32 %d1, i64 2
+    %v3 = insertelement <4 x i32> %v2, i32 %d1, i64 3
+    ret <4 x i32> %v3
+}
\ No newline at end of file

>From c4ed841e5589995afa4bf10e99f7c477ba684c49 Mon Sep 17 00:00:00 2001
From: Soumik15630m <soumik15630m at gmail.com>
Date: Tue, 20 Jan 2026 23:42:42 +0530
Subject: [PATCH 03/12] [SLP] Handle out-of-bounds extractelement indices in
 getExtractIndex directly - a global fix

---
 llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp     | 13 +++++++++++--
 .../X86/crash-on-out-of-bound-extract.ll            | 12 +++---------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 8125eb27a2e98..bca31a80966cd 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -902,7 +902,16 @@ static std::optional<unsigned> getExtractIndex(const Instruction *E) {
     auto *CI = dyn_cast<ConstantInt>(E->getOperand(1));
     if (!CI)
       return std::nullopt;
-    return CI->getZExtValue();
+    // Check if the index is out of bound  - we can get the source vector from operand 0
+    unsigned Idx =  CI->getZExtValue();
+    if (auto *VecTy = dyn_cast<FixedVectorType>(E->getOperand(0)->getType()))
+    {
+      if (Idx >= VecTy->getNumElements())
+      {
+        return std::nullopt;
+      }
+    }
+    return Idx;
   }
   auto *EI = cast<ExtractValueInst>(E);
   if (EI->getNumIndices() != 1)
@@ -14383,7 +14392,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
         // vectorized tree.
         // Also, avoid adjusting the cost for extractelements with multiple uses
         // in different graph entries.
-        auto *EE = cast<ExtractElementInst>(V);
+        auto *EE = dyn_cast<ExtractElementInst>(V); // using dyncast instead of cast to rule out the crash if v is not an extract elementinst
         VecBase = EE->getVectorOperand();
         UniqueBases.insert(VecBase);
         ArrayRef<TreeEntry *> VEs = R.getTreeEntries(V);
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/crash-on-out-of-bound-extract.ll b/llvm/test/Transforms/SLPVectorizer/X86/crash-on-out-of-bound-extract.ll
index d971f537f6330..c9fa9f855b2d2 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/crash-on-out-of-bound-extract.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/crash-on-out-of-bound-extract.ll
@@ -1,12 +1,6 @@
-; RUN: opt -passes=slp-vectorizer -S < %s | FileCheck %s
+; RUN: opt -passes=slp-vectorizer -S < %s > /dev/null
 
 define <4 x i32> @test(<4 x i32> %A){
-; CHECK-LABEL: @test(
-; CHECK-NEXT: entry:
-; CHECK-NEXT:   [[TMP0:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> poison, <4 x i32> <i32 0, i32 1, i32 3, i32 1>
-; CHECK-NEXT:   [[TMP1:%.*]] = sdiv <4 x i32> [[A]], [[TMP0]]
-; CHECK-NEXT:   ret <4 x i32> [[TMP1]]
-;
 entry:
     %e0 = extractelement <4 x i32> %A, i64 0
     %e1 = extractelement <4 x i32> %A, i64 1
@@ -19,7 +13,7 @@ entry:
     %d3 = sdiv i32 %oob, %e1
     %v0 = insertelement <4 x i32> poison, i32 %d0, i64 0
     %v1 = insertelement <4 x i32> %v0, i32 %d1, i64 1
-    %v2 = insertelement <4 x i32> %v1, i32 %d1, i64 2
-    %v3 = insertelement <4 x i32> %v2, i32 %d1, i64 3
+    %v2 = insertelement <4 x i32> %v1, i32 %d2, i64 2
+    %v3 = insertelement <4 x i32> %v2, i32 %d3, i64 3
     ret <4 x i32> %v3
 }
\ No newline at end of file

>From 9d97d027fc62c0ea292c155148d4e3d4c6aeba1e Mon Sep 17 00:00:00 2001
From: Soumik15630m <soumik15630m at gmail.com>
Date: Wed, 21 Jan 2026 00:25:32 +0530
Subject: [PATCH 04/12] [SLP] Handle out-of-bounds extractelement indices in
 getExtractIndex directly LLVM style

---
 .../Transforms/Vectorize/SLPVectorizer.cpp    | 23 +++++++------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index bca31a80966cd..cef8fae5f6943 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -904,13 +904,13 @@ static std::optional<unsigned> getExtractIndex(const Instruction *E) {
       return std::nullopt;
     // Check if the index is out of bound  - we can get the source vector from operand 0
     unsigned Idx =  CI->getZExtValue();
-    if (auto *VecTy = dyn_cast<FixedVectorType>(E->getOperand(0)->getType()))
-    {
-      if (Idx >= VecTy->getNumElements())
-      {
-        return std::nullopt;
-      }
-    }
+    //argument E passed to getExtractIndex is of type "const Instrunction * "
+    //but the instrunction class doesn't consist the getVectorOperandType
+    //so just a simple casting to ExtractElementInst
+    auto *EE = cast<ExtractElementInst>(E);
+    const unsigned VF = ::getNumElements(EE->getVectorOperandType());
+    if (Idx >= VF)
+      return std::nullopt;
     return Idx;
   }
   auto *EI = cast<ExtractValueInst>(E);
@@ -15051,14 +15051,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
       }
       if (DemandedElts.isZero())
         DemandedElts = APInt::getZero(getNumElements(SrcVecTy));
-      unsigned ExtIdx = *getExtractIndex(I);
-      //Out-of-bounds extractelement produces poison.So it do no corresponds to a concrete vector lane,
-      // so instead of treating it as an invalid pattern we can avoid marking any demanded element
-      if (ExtIdx  < DemandedElts.getBitWidth())
-      {
-        DemandedElts.setBit(ExtIdx);
-      }
-      // DemandedElts.setBit(*getExtractIndex(I));
+      DemandedElts.setBit(*getExtractIndex(I));
       return InstructionCost(TTI::TCC_Free);
     };
     auto GetVectorCost = [&, &TTI = *TTI](InstructionCost CommonCost) {

>From 03024bc621da2df7f5176e1858f0ab4bbe89a255 Mon Sep 17 00:00:00 2001
From: Soumik15630m <soumik15630m at gmail.com>
Date: Wed, 21 Jan 2026 00:36:58 +0530
Subject: [PATCH 05/12] [SLP] Handle out-of-bounds extractelement indices in
 getExtractIndex directly LLVM style

---
 llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index cef8fae5f6943..8239e6fa44d93 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -907,8 +907,8 @@ static std::optional<unsigned> getExtractIndex(const Instruction *E) {
     //argument E passed to getExtractIndex is of type "const Instrunction * "
     //but the instrunction class doesn't consist the getVectorOperandType
     //so just a simple casting to ExtractElementInst
-    auto *EE = cast<ExtractElementInst>(E);
-    const unsigned VF = ::getNumElements(EE->getVectorOperandType());
+    auto *EE = dyn_cast<ExtractElementInst>(E);
+    const unsigned VF = ::getNumElements(EE->getVectorOperandType());// can be implemented inside an IF statement - to be safe
     if (Idx >= VF)
       return std::nullopt;
     return Idx;

>From e8ddd06bf0d4ec0f152e0d559048aa6b353ff086 Mon Sep 17 00:00:00 2001
From: Soumik15630m <soumik15630m at gmail.com>
Date: Wed, 21 Jan 2026 00:41:59 +0530
Subject: [PATCH 06/12] [SLP] Handle out-of-bounds extractelement indices in
 getExtractIndex

---
 llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 8239e6fa44d93..5c28f0e27c759 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -14392,7 +14392,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
         // vectorized tree.
         // Also, avoid adjusting the cost for extractelements with multiple uses
         // in different graph entries.
-        auto *EE = dyn_cast<ExtractElementInst>(V); // using dyncast instead of cast to rule out the crash if v is not an extract elementinst
+        auto *EE = cast<ExtractElementInst>(V);
         VecBase = EE->getVectorOperand();
         UniqueBases.insert(VecBase);
         ArrayRef<TreeEntry *> VEs = R.getTreeEntries(V);

>From 96004b83fdc7adb132514a8726415bb719623477 Mon Sep 17 00:00:00 2001
From: Soumik15630m <soumik15630m at gmail.com>
Date: Wed, 21 Jan 2026 00:43:41 +0530
Subject: [PATCH 07/12] [SLP] Handle out-of-bounds extractelement indices in
 getExtractIndex ---

---
 llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 5c28f0e27c759..e0ad343ed28ac 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -907,7 +907,7 @@ static std::optional<unsigned> getExtractIndex(const Instruction *E) {
     //argument E passed to getExtractIndex is of type "const Instrunction * "
     //but the instrunction class doesn't consist the getVectorOperandType
     //so just a simple casting to ExtractElementInst
-    auto *EE = dyn_cast<ExtractElementInst>(E);
+    auto *EE = cast<ExtractElementInst>(E);
     const unsigned VF = ::getNumElements(EE->getVectorOperandType());// can be implemented inside an IF statement - to be safe
     if (Idx >= VF)
       return std::nullopt;

>From 4495d448d125e1f67906b90f24b44d2982f80e40 Mon Sep 17 00:00:00 2001
From: Soumik15630m <soumik15630m at gmail.com>
Date: Wed, 21 Jan 2026 01:24:40 +0530
Subject: [PATCH 08/12] [SLP] Handle out-of-bounds extractelement indices in
 getExtractIndex -----

---
 llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index e0ad343ed28ac..abdd8d2101a54 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -904,9 +904,6 @@ static std::optional<unsigned> getExtractIndex(const Instruction *E) {
       return std::nullopt;
     // Check if the index is out of bound  - we can get the source vector from operand 0
     unsigned Idx =  CI->getZExtValue();
-    //argument E passed to getExtractIndex is of type "const Instrunction * "
-    //but the instrunction class doesn't consist the getVectorOperandType
-    //so just a simple casting to ExtractElementInst
     auto *EE = cast<ExtractElementInst>(E);
     const unsigned VF = ::getNumElements(EE->getVectorOperandType());// can be implemented inside an IF statement - to be safe
     if (Idx >= VF)

>From 5290cd95185ccdb8ef936ab0e1c1a37ac1e0467e Mon Sep 17 00:00:00 2001
From: Soumik15630m <soumik15630m at gmail.com>
Date: Wed, 21 Jan 2026 01:34:47 +0530
Subject: [PATCH 09/12] [SLP] Handle out-of-bounds extractelement indices in
 getExtractIndex ----- SImplified implementation

---
 llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index abdd8d2101a54..3c1145c4729df 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -905,7 +905,7 @@ static std::optional<unsigned> getExtractIndex(const Instruction *E) {
     // Check if the index is out of bound  - we can get the source vector from operand 0
     unsigned Idx =  CI->getZExtValue();
     auto *EE = cast<ExtractElementInst>(E);
-    const unsigned VF = ::getNumElements(EE->getVectorOperandType());// can be implemented inside an IF statement - to be safe
+    const unsigned VF = ::getNumElements(EE->getVectorOperandType());
     if (Idx >= VF)
       return std::nullopt;
     return Idx;

>From 124dc3027ac0d61105aa10338affb18e70d00ca8 Mon Sep 17 00:00:00 2001
From: Soumik15630m <soumik15630m at gmail.com>
Date: Wed, 21 Jan 2026 04:35:31 +0530
Subject: [PATCH 10/12] [SLP] formatting fixed

---
 llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 3c1145c4729df..402a7cd879b98 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -903,7 +903,7 @@ static std::optional<unsigned> getExtractIndex(const Instruction *E) {
     if (!CI)
       return std::nullopt;
     // Check if the index is out of bound  - we can get the source vector from operand 0
-    unsigned Idx =  CI->getZExtValue();
+    unsigned Idx = CI->getZExtValue();
     auto *EE = cast<ExtractElementInst>(E);
     const unsigned VF = ::getNumElements(EE->getVectorOperandType());
     if (Idx >= VF)

>From cdea2fc584a3e1cc1f8a1fc48d02979c04904a8e Mon Sep 17 00:00:00 2001
From: Soumik15630m <soumik15630m at gmail.com>
Date: Wed, 21 Jan 2026 04:40:54 +0530
Subject: [PATCH 11/12] [SLP] formatting fixed

---
 llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 402a7cd879b98..a002b0e4011bb 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -902,7 +902,8 @@ static std::optional<unsigned> getExtractIndex(const Instruction *E) {
     auto *CI = dyn_cast<ConstantInt>(E->getOperand(1));
     if (!CI)
       return std::nullopt;
-    // Check if the index is out of bound  - we can get the source vector from operand 0
+    // Check if the index is out of bound  - we can get the source vector from
+    // operand 0
     unsigned Idx = CI->getZExtValue();
     auto *EE = cast<ExtractElementInst>(E);
     const unsigned VF = ::getNumElements(EE->getVectorOperandType());

>From 976e5b2e5244bccdebb81d027a6b365e6ba3ce3d Mon Sep 17 00:00:00 2001
From: Soumik15630m <soumik15630m at gmail.com>
Date: Mon, 26 Jan 2026 00:03:18 +0530
Subject: [PATCH 12/12] [SLP] Updated the test ...

---
 .../X86/crash-on-out-of-bound-extract.ll      | 38 +++++++++++--------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/llvm/test/Transforms/SLPVectorizer/X86/crash-on-out-of-bound-extract.ll b/llvm/test/Transforms/SLPVectorizer/X86/crash-on-out-of-bound-extract.ll
index c9fa9f855b2d2..28335c41278aa 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/crash-on-out-of-bound-extract.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/crash-on-out-of-bound-extract.ll
@@ -1,19 +1,25 @@
-; RUN: opt -passes=slp-vectorizer -S < %s > /dev/null
+; RUN: opt -passes=slp-vectorizer -S < %s | FileCheck %s
+
+; CHECK-LABEL: @test(
+; CHECK: shufflevector <4 x i32>
+; CHECK: sdiv <4 x i32>
+; CHECK-NOT: extractelement
+; CHECK-NOT: insertelement
 
 define <4 x i32> @test(<4 x i32> %A){
 entry:
-    %e0 = extractelement <4 x i32> %A, i64 0
-    %e1 = extractelement <4 x i32> %A, i64 1
-    %e2 = extractelement <4 x i32> %A, i64 2
-    %e3 = extractelement <4 x i32> %A, i64 3
-    %oob = extractelement <4 x i32> %A, i64 4
-    %d0 = sdiv i32 %e0, %e0
-    %d1 = sdiv i32 %oob, %e1
-    %d2 = sdiv i32 %e2, %e3
-    %d3 = sdiv i32 %oob, %e1
-    %v0 = insertelement <4 x i32> poison, i32 %d0, i64 0
-    %v1 = insertelement <4 x i32> %v0, i32 %d1, i64 1
-    %v2 = insertelement <4 x i32> %v1, i32 %d2, i64 2
-    %v3 = insertelement <4 x i32> %v2, i32 %d3, i64 3
-    ret <4 x i32> %v3
-}
\ No newline at end of file
+  %e0 = extractelement <4 x i32> %A, i64 0
+  %e1 = extractelement <4 x i32> %A, i64 1
+  %e2 = extractelement <4 x i32> %A, i64 2
+  %e3 = extractelement <4 x i32> %A, i64 3
+  %oob = extractelement <4 x i32> %A, i64 4
+  %d0 = sdiv i32 %e0, %e0
+  %d1 = sdiv i32 %oob, %e1
+  %d2 = sdiv i32 %e2, %e3
+  %d3 = sdiv i32 %oob, %e1
+  %v0 = insertelement <4 x i32> poison, i32 %d0, i64 0
+  %v1 = insertelement <4 x i32> %v0, i32 %d1, i64 1
+  %v2 = insertelement <4 x i32> %v1, i32 %d2, i64 2
+  %v3 = insertelement <4 x i32> %v2, i32 %d3, i64 3
+  ret <4 x i32> %v3
+}



More information about the llvm-commits mailing list