Skip to content

Commit e93bc65

Browse files
committed
[LV] Peek through bitcasts when performing CSE
LoopVectorize performs CSE of induction variable instructions. Adds bitcasts to the worklist as well.
1 parent 9d4c227 commit e93bc65

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,8 +2642,8 @@ namespace {
26422642

26432643
struct CSEDenseMapInfo {
26442644
static bool canHandle(const Instruction *I) {
2645-
return isa<InsertElementInst>(I) || isa<ExtractElementInst>(I) ||
2646-
isa<ShuffleVectorInst>(I) || isa<GetElementPtrInst>(I);
2645+
return isa<InsertElementInst, ExtractElementInst, ShuffleVectorInst,
2646+
GetElementPtrInst, BitCastInst>(I);
26472647
}
26482648

26492649
static inline Instruction *getEmptyKey() {

llvm/test/Transforms/LoopVectorize/X86/cse-bitcast.ll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ define void @cse_bitcast(i16 %val, half %fval, ptr %p, i64 %n) {
4949
; CHECK-NEXT: [[TMP14:%.*]] = shufflevector <4 x half> [[TMP13]], <4 x half> [[BROADCAST_SPLAT5]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
5050
; CHECK-NEXT: [[INTERLEAVED_VEC:%.*]] = shufflevector <8 x half> [[TMP14]], <8 x half> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
5151
; CHECK-NEXT: store <8 x half> [[INTERLEAVED_VEC]], ptr [[NEXT_GEP]], align 2
52-
; CHECK-NEXT: [[TMP15:%.*]] = bitcast <4 x i16> [[BROADCAST_SPLAT]] to <4 x half>
53-
; CHECK-NEXT: [[TMP16:%.*]] = shufflevector <4 x half> [[TMP15]], <4 x half> [[BROADCAST_SPLAT5]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
54-
; CHECK-NEXT: [[INTERLEAVED_VEC7:%.*]] = shufflevector <8 x half> [[TMP16]], <8 x half> poison, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
55-
; CHECK-NEXT: store <8 x half> [[INTERLEAVED_VEC7]], ptr [[NEXT_GEP6]], align 2
52+
; CHECK-NEXT: store <8 x half> [[INTERLEAVED_VEC]], ptr [[NEXT_GEP6]], align 2
5653
; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 8
5754
; CHECK-NEXT: [[TMP17:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
5855
; CHECK-NEXT: br i1 [[TMP17]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]

0 commit comments

Comments
 (0)