[PATCH] D136099: [instsimplify] Move (extelt (inselt Vec, Value, Index), Index) -> Value from InstCombine
Daniel Sanders via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 17 15:22:31 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG021e6e05d3d9: [instsimplify] Move (extelt (inselt Vec, Value, Index), Index) -> Value from… (authored by dsanders).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136099/new/
https://reviews.llvm.org/D136099
Files:
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
llvm/test/Transforms/InstCombine/vector-inseltextelt.ll
llvm/test/Transforms/InstSimplify/vector-inseltextelt.ll
Index: llvm/test/Transforms/InstSimplify/vector-inseltextelt.ll
===================================================================
--- llvm/test/Transforms/InstSimplify/vector-inseltextelt.ll
+++ llvm/test/Transforms/InstSimplify/vector-inseltextelt.ll
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
; extracting a just-inserted element should yield the original value
define float @constant_index(<4 x float> %x, float %val) {
Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -474,11 +474,6 @@
if (auto *I = dyn_cast<Instruction>(SrcVec)) {
if (auto *IE = dyn_cast<InsertElementInst>(I)) {
- // If the possibly-variable indices are trivially known to be equal
- // (because they are the same operand) then use the value that was
- // inserted directly.
- if (IE->getOperand(2) == Index)
- return replaceInstUsesWith(EI, IE->getOperand(1));
// instsimplify already handled the case where the indices are constants
// and equal by value, if both are constants, they must not be the same
// value, extract from the pre-inserted value instead.
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4857,6 +4857,14 @@
if (Value *Elt = findScalarElement(Vec, IdxC->getZExtValue()))
return Elt;
} else {
+ // extractelt x, (insertelt y, elt, n), n -> elt
+ // If the possibly-variable indices are trivially known to be equal
+ // (because they are the same operand) then use the value that was
+ // inserted directly.
+ auto *IE = dyn_cast<InsertElementInst>(Vec);
+ if (IE && IE->getOperand(2) == Idx)
+ return IE->getOperand(1);
+
// The index is not relevant if our vector is a splat.
if (Value *Splat = getSplatValue(Vec))
return Splat;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136099.468349.patch
Type: text/x-patch
Size: 2275 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221017/78042b06/attachment.bin>
More information about the llvm-commits
mailing list