File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -137,8 +137,13 @@ Value *GenXGEPLowering::visitPtrToIntInst(PtrToIntInst &PTI) {
137137 // The `addrspacecast` is just no-op so it can be eliminated
138138 Src = Cast->getOperand (0 );
139139 } else if (isa<BitCastInst>(Cast)) {
140+ auto *Arg = Cast->getOperand (0 );
141+ auto *ArgTy = Arg->getType ();
142+ auto *CastTy = Cast->getType ();
143+ if (ArgTy->isVectorTy () != CastTy->isVectorTy ())
144+ break ;
140145 // The `bitcast` is just no-op so it can be eliminated
141- Src = Cast-> getOperand ( 0 ) ;
146+ Src = Arg ;
142147 } else {
143148 // We found `inttoptr`, getting rid of `ptrtoint`
144149 if (isa<IntToPtrInst>(Cast))
Original file line number Diff line number Diff line change @@ -63,3 +63,14 @@ label: ; preds = %entry
6363 %splat = shufflevector <16 x i64 > %ins , <16 x i64 > undef , <16 x i32 > zeroinitializer
6464 ret void
6565}
66+
67+ ; CHECK-LABEL: @test_bitcast_vector_to_scalar
68+ define i64 @test_bitcast_vector_to_scalar (<1 x i8* > %vptr ) {
69+ %ptr = bitcast <1 x i8* > %vptr to i8*
70+ %gep = getelementptr i8 , i8* %ptr , i32 123
71+ %addr = ptrtoint i8* %gep to i64
72+ ; CHECK: [[PTI:%[^ ]+]] = ptrtoint i8* %ptr to i64
73+ ; CHECK: [[ADD:%[^ ]+]] = add i64 [[PTI]], 123
74+ ; CHECK: ret i64 [[ADD]]
75+ ret i64 %addr
76+ }
You can’t perform that action at this time.
0 commit comments