Skip to content

Commit c746edf

Browse files
committed
[AggressiveInstCombine] Add pre-commit tests. NFC.
1 parent 346f48e commit c746edf

File tree

1 file changed

+47
-0
lines changed
  • llvm/test/Transforms/AggressiveInstCombine/X86

1 file changed

+47
-0
lines changed

llvm/test/Transforms/AggressiveInstCombine/X86/or-load.ll

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,3 +2505,50 @@ entry:
25052505
%or = or disjoint i32 %shl, %conv.2
25062506
ret i32 %or
25072507
}
2508+
2509+
@g = global i64 1060856922120
2510+
2511+
; Make sure we use the correct memory location for alias analysis.
2512+
define i64 @loadcombine_consecutive_mayalias(ptr %p) {
2513+
; LE-LABEL: @loadcombine_consecutive_mayalias(
2514+
; LE-NEXT: entry:
2515+
; LE-NEXT: [[LOAD1:%.*]] = load i64, ptr [[P:%.*]], align 4
2516+
; LE-NEXT: store i8 0, ptr getelementptr inbounds nuw (i8, ptr @g, i64 4), align 4
2517+
; LE-NEXT: [[RES:%.*]] = lshr i64 [[LOAD1]], 32
2518+
; LE-NEXT: ret i64 [[RES]]
2519+
;
2520+
; BE-LABEL: @loadcombine_consecutive_mayalias(
2521+
; BE-NEXT: entry:
2522+
; BE-NEXT: [[LOAD1:%.*]] = load i32, ptr [[P:%.*]], align 4
2523+
; BE-NEXT: [[GEP1:%.*]] = getelementptr i8, ptr [[P]], i64 4
2524+
; BE-NEXT: [[GEP2:%.*]] = getelementptr i8, ptr [[P]], i64 5
2525+
; BE-NEXT: store i8 0, ptr getelementptr inbounds nuw (i8, ptr @g, i64 4), align 4
2526+
; BE-NEXT: [[LOAD2:%.*]] = load i8, ptr [[GEP1]], align 4
2527+
; BE-NEXT: [[LOAD3:%.*]] = load i24, ptr [[GEP2]], align 1
2528+
; BE-NEXT: [[ZEXT1:%.*]] = zext i24 [[LOAD3]] to i64
2529+
; BE-NEXT: [[SHL1:%.*]] = shl i64 [[ZEXT1]], 40
2530+
; BE-NEXT: [[ZEXT2:%.*]] = zext i8 [[LOAD2]] to i64
2531+
; BE-NEXT: [[SHL2:%.*]] = shl i64 [[ZEXT2]], 32
2532+
; BE-NEXT: [[OR1:%.*]] = or i64 [[SHL1]], [[SHL2]]
2533+
; BE-NEXT: [[ZEXT3:%.*]] = zext i32 [[LOAD1]] to i64
2534+
; BE-NEXT: [[OR2:%.*]] = or i64 [[OR1]], [[ZEXT3]]
2535+
; BE-NEXT: [[RES:%.*]] = lshr i64 [[OR2]], 32
2536+
; BE-NEXT: ret i64 [[RES]]
2537+
;
2538+
entry:
2539+
%load1 = load i32, ptr %p, align 4
2540+
%gep1 = getelementptr i8, ptr %p, i64 4
2541+
%gep2 = getelementptr i8, ptr %p, i64 5
2542+
store i8 0, ptr getelementptr inbounds nuw (i8, ptr @g, i64 4), align 4
2543+
%load2 = load i8, ptr %gep1, align 4
2544+
%load3 = load i24, ptr %gep2, align 1
2545+
%zext1 = zext i24 %load3 to i64
2546+
%shl1 = shl i64 %zext1, 40
2547+
%zext2 = zext i8 %load2 to i64
2548+
%shl2 = shl i64 %zext2, 32
2549+
%or1 = or i64 %shl1, %shl2
2550+
%zext3 = zext i32 %load1 to i64
2551+
%or2 = or i64 %or1, %zext3
2552+
%res = lshr i64 %or2, 32
2553+
ret i64 %res
2554+
}

0 commit comments

Comments
 (0)