File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed
test/Transforms/VectorCombine/AArch64 Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -2652,8 +2652,12 @@ bool VectorCombine::shrinkType(llvm::Instruction &I) {
2652
2652
return false ;
2653
2653
2654
2654
Value *Op0 = ZExted;
2655
- if (auto *OI = dyn_cast<Instruction>(OtherOperand))
2656
- Builder.SetInsertPoint (OI->getNextNode ());
2655
+ if (auto *OI = dyn_cast<Instruction>(OtherOperand)) {
2656
+ if (isa<PHINode>(OI))
2657
+ Builder.SetInsertPoint (OI->getParent ()->getFirstInsertionPt ());
2658
+ else
2659
+ Builder.SetInsertPoint (OI->getNextNode ());
2660
+ }
2657
2661
Value *Op1 = Builder.CreateTrunc (OtherOperand, SmallTy);
2658
2662
Builder.SetInsertPoint (&I);
2659
2663
// Keep the order of operands the same
Original file line number Diff line number Diff line change @@ -73,4 +73,31 @@ entry:
73
73
ret i32 %6
74
74
}
75
75
76
+ define i32 @phi_bug (<16 x i32 > %a , ptr %b ) {
77
+ ; CHECK-LABEL: @phi_bug(
78
+ ; CHECK-NEXT: entry:
79
+ ; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <16 x i8>, ptr [[B:%.*]], align 1
80
+ ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
81
+ ; CHECK: vector.body:
82
+ ; CHECK-NEXT: [[A_PHI:%.*]] = phi <16 x i32> [ [[A:%.*]], [[ENTRY:%.*]] ]
83
+ ; CHECK-NEXT: [[WIDE_LOAD_PHI:%.*]] = phi <16 x i8> [ [[WIDE_LOAD]], [[ENTRY]] ]
84
+ ; CHECK-NEXT: [[TMP0:%.*]] = trunc <16 x i32> [[A_PHI]] to <16 x i8>
85
+ ; CHECK-NEXT: [[TMP1:%.*]] = and <16 x i8> [[WIDE_LOAD_PHI]], [[TMP0]]
86
+ ; CHECK-NEXT: [[TMP2:%.*]] = zext <16 x i8> [[TMP1]] to <16 x i32>
87
+ ; CHECK-NEXT: [[TMP3:%.*]] = tail call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> [[TMP2]])
88
+ ; CHECK-NEXT: ret i32 [[TMP3]]
89
+ ;
90
+ entry:
91
+ %wide.load = load <16 x i8 >, ptr %b , align 1
92
+ br label %vector.body
93
+
94
+ vector.body:
95
+ %a.phi = phi <16 x i32 > [ %a , %entry ]
96
+ %wide.load.phi = phi <16 x i8 > [ %wide.load , %entry ]
97
+ %0 = zext <16 x i8 > %wide.load.phi to <16 x i32 >
98
+ %1 = and <16 x i32 > %0 , %a.phi
99
+ %2 = tail call i32 @llvm.vector.reduce.add.v16i32 (<16 x i32 > %1 )
100
+ ret i32 %2
101
+ }
102
+
76
103
declare i32 @llvm.vector.reduce.add.v16i32 (<16 x i32 >)
You can’t perform that action at this time.
0 commit comments