mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 17:24:48 +00:00
In the function InstCombiner::visitExtractElementInst() removed the limitation that extract is promoted over a cast only if the cast has only one use.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179786 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -278,10 +278,10 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
|
|||||||
} else if (CastInst *CI = dyn_cast<CastInst>(I)) {
|
} else if (CastInst *CI = dyn_cast<CastInst>(I)) {
|
||||||
// Canonicalize extractelement(cast) -> cast(extractelement)
|
// Canonicalize extractelement(cast) -> cast(extractelement)
|
||||||
// bitcasts can change the number of vector elements and they cost nothing
|
// bitcasts can change the number of vector elements and they cost nothing
|
||||||
if (CI->hasOneUse() && EI.hasOneUse() &&
|
if (CI->hasOneUse() && (CI->getOpcode() != Instruction::BitCast)) {
|
||||||
(CI->getOpcode() != Instruction::BitCast)) {
|
Value *EE = InsertNewInstWith(
|
||||||
Value *EE = Builder->CreateExtractElement(CI->getOperand(0),
|
ExtractElementInst::Create(CI->getOperand(0), EI.getIndexOperand()),
|
||||||
EI.getIndexOperand());
|
*CI);
|
||||||
return CastInst::Create(CI->getOpcode(), EE, EI.getType());
|
return CastInst::Create(CI->getOpcode(), EE, EI.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
test/Transforms/InstCombine/vec_extract_2elts.ll
Normal file
12
test/Transforms/InstCombine/vec_extract_2elts.ll
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
||||||
|
|
||||||
|
define void @test(<4 x i32> %v, i64 *%r1, i64 *%r2) {
|
||||||
|
;CHECK: %1 = extractelement <4 x i32> %v, i32 0
|
||||||
|
;CHECK: %2 = zext i32 %1 to i64
|
||||||
|
%1 = zext <4 x i32> %v to <4 x i64>
|
||||||
|
%2 = extractelement <4 x i64> %1, i32 0
|
||||||
|
store i64 %2, i64 *%r1
|
||||||
|
store i64 %2, i64 *%r2
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user