File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
lib/Transforms/InstCombine
test/Transforms/InstCombine Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -828,8 +828,8 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
828
828
829
829
// bswap(trunc(bswap(x))) -> trunc(lshr(x, c))
830
830
if (match (IIOperand, m_Trunc (m_BSwap (m_Value (X))))) {
831
- unsigned C = X->getType ()->getPrimitiveSizeInBits () -
832
- IIOperand->getType ()->getPrimitiveSizeInBits ();
831
+ unsigned C = X->getType ()->getScalarSizeInBits () -
832
+ IIOperand->getType ()->getScalarSizeInBits ();
833
833
Value *CV = ConstantInt::get (X->getType (), C);
834
834
Value *V = Builder.CreateLShr (X, CV);
835
835
return new TruncInst (V, IIOperand->getType ());
Original file line number Diff line number Diff line change @@ -39,7 +39,9 @@ define i16 @test7(i32 %A) {
39
39
40
40
define <2 x i16 > @test7_vector (<2 x i32 > %A ) {
41
41
; CHECK-LABEL: @test7_vector(
42
- ; CHECK-NEXT: ret <2 x i16> undef
42
+ ; CHECK-NEXT: [[TMP1:%.*]] = lshr <2 x i32> [[A:%.*]], <i32 16, i32 16>
43
+ ; CHECK-NEXT: [[D:%.*]] = trunc <2 x i32> [[TMP1]] to <2 x i16>
44
+ ; CHECK-NEXT: ret <2 x i16> [[D]]
43
45
;
44
46
%B = tail call <2 x i32 > @llvm.bswap.v2i32 (<2 x i32 > %A ) nounwind
45
47
%C = trunc <2 x i32 > %B to <2 x i16 >
@@ -61,7 +63,9 @@ define i16 @test8(i64 %A) {
61
63
62
64
define <2 x i16 > @test8_vector (<2 x i64 > %A ) {
63
65
; CHECK-LABEL: @test8_vector(
64
- ; CHECK-NEXT: ret <2 x i16> undef
66
+ ; CHECK-NEXT: [[TMP1:%.*]] = lshr <2 x i64> [[A:%.*]], <i64 48, i64 48>
67
+ ; CHECK-NEXT: [[D:%.*]] = trunc <2 x i64> [[TMP1]] to <2 x i16>
68
+ ; CHECK-NEXT: ret <2 x i16> [[D]]
65
69
;
66
70
%B = tail call <2 x i64 > @llvm.bswap.v2i64 (<2 x i64 > %A ) nounwind
67
71
%C = trunc <2 x i64 > %B to <2 x i16 >
You can’t perform that action at this time.
0 commit comments