diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-04-14 23:02:14 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-04-14 23:02:14 +0000 |
| commit | 7bfdd0abe10b593465677599bc292e0ae89c9aee (patch) | |
| tree | a945496b3d8d91c8acec70a7c6acd1a42cbb6469 /llvm/lib/Transforms | |
| parent | 45ab14d084d534d71cf264daa6efb4da68f475d6 (diff) | |
| download | bcm5719-llvm-7bfdd0abe10b593465677599bc292e0ae89c9aee.tar.gz bcm5719-llvm-7bfdd0abe10b593465677599bc292e0ae89c9aee.zip | |
Implement Transforms/InstCombine/vec_extract_elt.ll, transforming:
define i32 @test(float %f) {
%tmp7 = insertelement <4 x float> undef, float %f, i32 0
%tmp17 = bitcast <4 x float> %tmp7 to <4 x i32>
%tmp19 = extractelement <4 x i32> %tmp17, i32 0
ret i32 %tmp19
}
into:
define i32 @test(float %f) {
%tmp19 = bitcast float %f to i32 ; <i32> [#uses=1]
ret i32 %tmp19
}
On PPC, this is the difference between:
_test:
mfspr r2, 256
oris r3, r2, 8192
mtspr 256, r3
stfs f1, -16(r1)
addi r3, r1, -16
addi r4, r1, -32
lvx v2, 0, r3
stvx v2, 0, r4
lwz r3, -32(r1)
mtspr 256, r2
blr
and:
_test:
stfs f1, -4(r1)
nop
nop
nop
lwz r3, -4(r1)
blr
llvm-svn: 36025
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 912ab2db608..c63ba68bc02 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -9109,6 +9109,17 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) { if (Value *Elt = FindScalarElement(EI.getOperand(0), IndexVal)) return ReplaceInstUsesWith(EI, Elt); + + // If the this extractelement is directly using a bitcast from a vector of + // the same number of elements, see if we can find the source element from + // it. In this case, we will end up needing to bitcast the scalars. + if (BitCastInst *BCI = dyn_cast<BitCastInst>(EI.getOperand(0))) { + if (const VectorType *VT = + dyn_cast<VectorType>(BCI->getOperand(0)->getType())) + if (VT->getNumElements() == VectorWidth) + if (Value *Elt = FindScalarElement(BCI->getOperand(0), IndexVal)) + return new BitCastInst(Elt, EI.getType()); + } } if (Instruction *I = dyn_cast<Instruction>(EI.getOperand(0))) { |

