Skip to content

Commit c1aa868

Browse files
committed
[InstCombine] Increase coverage of shuffle-gep
There is an uncovered codepath in InstCombineVectorOps, where a new GEP instruction is created via buildNew. Fix this coverage hole.
1 parent 5837194 commit c1aa868

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,6 @@ static Value *buildNew(Instruction *I, ArrayRef<Value*> NewOps,
19781978
DestTy);
19791979
}
19801980
case Instruction::GetElementPtr: {
1981-
llvm_unreachable("Foo");
19821981
Value *Ptr = NewOps[0];
19831982
ArrayRef<Value*> Idx = NewOps.slice(1);
19841983
return Builder.CreateGEP(cast<GEPOperator>(I)->getSourceElementType(),

llvm/test/Transforms/InstCombine/vec_shuffle.ll

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; REQURIES: asserts
3-
; RUN: not --crash opt %s -passes=instcombine -disable-output
2+
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
43

54
declare <2 x half> @llvm.fabs.v2f16(<2 x half>)
65
declare <2 x float> @llvm.fabs.v2f32(<2 x float>)
@@ -251,10 +250,9 @@ define <2 x i8> @test13a(i8 %x1, i8 %x2) {
251250

252251
define <1 x ptr> @shuffle_gep(ptr %x1, ptr %x2) {
253252
; CHECK-LABEL: @shuffle_gep(
254-
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x i8> poison, i8 [[X2:%.*]], i64 0
255-
; CHECK-NEXT: [[TMP2:%.*]] = insertelement <2 x i8> [[TMP1]], i8 [[X1:%.*]], i64 1
256-
; CHECK-NEXT: [[D:%.*]] = add <2 x i8> [[TMP2]], <i8 7, i8 5>
257-
; CHECK-NEXT: ret <2 x i8> [[D]]
253+
; CHECK-NEXT: [[TMP1:%.*]] = insertelement <1 x ptr> poison, ptr [[X2:%.*]], i64 0
254+
; CHECK-NEXT: [[RET:%.*]] = getelementptr i8, <1 x ptr> [[TMP1]], i64 5
255+
; CHECK-NEXT: ret <1 x ptr> [[RET]]
258256
;
259257
%ins.1 = insertelement <2 x ptr> poison, ptr %x1, i32 0
260258
%ins.2 = insertelement <2 x ptr> %ins.1, ptr %x2, i32 1

0 commit comments

Comments
 (0)