forked from OSchip/llvm-project
[InstCombine] Add test for GEP difference with bitcasts (NFC)
This commit is contained in:
parent
a9a6e20012
commit
3eab6c5911
|
@ -369,3 +369,22 @@ define i64 @gep_diff_second_inbounds(i8* %foo, i64 %i, i64 %j) {
|
|||
%sub = sub i64 %cast1, %cast2
|
||||
ret i64 %sub
|
||||
}
|
||||
|
||||
define i64 @gep_diff_with_bitcast(i64* %p, i64 %idx) {
|
||||
; CHECK-LABEL: @gep_diff_with_bitcast(
|
||||
; CHECK-NEXT: [[I0:%.*]] = bitcast i64* [[P:%.*]] to [4 x i64]*
|
||||
; CHECK-NEXT: [[I1:%.*]] = getelementptr inbounds [4 x i64], [4 x i64]* [[I0]], i64 [[IDX:%.*]]
|
||||
; CHECK-NEXT: [[I3:%.*]] = ptrtoint [4 x i64]* [[I1]] to i64
|
||||
; CHECK-NEXT: [[I4:%.*]] = ptrtoint i64* [[P]] to i64
|
||||
; CHECK-NEXT: [[I5:%.*]] = sub nuw i64 [[I3]], [[I4]]
|
||||
; CHECK-NEXT: [[I6:%.*]] = lshr i64 [[I5]], 5
|
||||
; CHECK-NEXT: ret i64 [[I6]]
|
||||
;
|
||||
%i0 = bitcast i64* %p to [4 x i64]*
|
||||
%i1 = getelementptr inbounds [4 x i64], [4 x i64]* %i0, i64 %idx
|
||||
%i3 = ptrtoint [4 x i64]* %i1 to i64
|
||||
%i4 = ptrtoint i64* %p to i64
|
||||
%i5 = sub nuw i64 %i3, %i4
|
||||
%i6 = lshr i64 %i5, 5
|
||||
ret i64 %i6
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue