1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
2 ; RUN: opt < %s -passes=gvn -S | FileCheck %s
4 define i1 @test_i1(ptr %a, ptr %b, ptr %c) {
5 ; CHECK-LABEL: define i1 @test_i1(
6 ; CHECK-SAME: ptr [[A:%.*]], ptr [[B:%.*]], ptr [[C:%.*]]) {
8 ; CHECK-NEXT: [[TMP0:%.*]] = load i1, ptr [[A]], align 1
9 ; CHECK-NEXT: store i1 [[TMP0]], ptr [[B]], align 1
10 ; CHECK-NEXT: ret i1 [[TMP0]]
13 %0 = load i1, ptr %a, align 1
14 store i1 %0, ptr %b, align 1
15 %1 = load i1, ptr %a, align 1
19 define i8 @test_i8(ptr %a, ptr %b, ptr %c) {
20 ; CHECK-LABEL: define i8 @test_i8(
21 ; CHECK-SAME: ptr [[A:%.*]], ptr [[B:%.*]], ptr [[C:%.*]]) {
23 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[A]], align 1
24 ; CHECK-NEXT: store i8 [[TMP0]], ptr [[B]], align 1
25 ; CHECK-NEXT: ret i8 [[TMP0]]
28 %0 = load i8, ptr %a, align 1
29 store i8 %0, ptr %b, align 1
30 %1 = load i8, ptr %a, align 1
34 define i32 @test_i32(ptr %a, ptr %b, ptr %c) {
35 ; CHECK-LABEL: define i32 @test_i32(
36 ; CHECK-SAME: ptr [[A:%.*]], ptr [[B:%.*]], ptr [[C:%.*]]) {
38 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4
39 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[B]], align 4
40 ; CHECK-NEXT: ret i32 [[TMP0]]
43 %0 = load i32, ptr %a, align 4
44 store i32 %0, ptr %b, align 4
45 %1 = load i32, ptr %a, align 4
49 define float @test_float(ptr %a, ptr %b, ptr %c) {
50 ; CHECK-LABEL: define float @test_float(
51 ; CHECK-SAME: ptr [[A:%.*]], ptr [[B:%.*]], ptr [[C:%.*]]) {
53 ; CHECK-NEXT: [[TMP0:%.*]] = load float, ptr [[A]], align 4
54 ; CHECK-NEXT: store float [[TMP0]], ptr [[B]], align 4
55 ; CHECK-NEXT: ret float [[TMP0]]
58 %0 = load float, ptr %a, align 4
59 store float %0, ptr %b, align 4
60 %1 = load float, ptr %a, align 4
64 define i32 @test_unaligned_store(ptr %a, ptr %b, ptr %c) {
65 ; CHECK-LABEL: define i32 @test_unaligned_store(
66 ; CHECK-SAME: ptr [[A:%.*]], ptr [[B:%.*]], ptr [[C:%.*]]) {
68 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4
69 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[B]], align 2
70 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[A]], align 4
71 ; CHECK-NEXT: ret i32 [[TMP1]]
74 %0 = load i32, ptr %a, align 4
75 store i32 %0, ptr %b, align 2
76 %1 = load i32, ptr %a, align 4
80 define i32 @test_unaligned_loads(ptr %a, ptr %b, ptr %c) {
81 ; CHECK-LABEL: define i32 @test_unaligned_loads(
82 ; CHECK-SAME: ptr [[A:%.*]], ptr [[B:%.*]], ptr [[C:%.*]]) {
84 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 2
85 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[B]], align 4
86 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[A]], align 2
87 ; CHECK-NEXT: ret i32 [[TMP1]]
90 %0 = load i32, ptr %a, align 2
91 store i32 %0, ptr %b, align 4
92 %1 = load i32, ptr %a, align 2
96 define i8 @test_modify_between(ptr %a, ptr %b, ptr %c) {
97 ; CHECK-LABEL: define i8 @test_modify_between(
98 ; CHECK-SAME: ptr [[A:%.*]], ptr [[B:%.*]], ptr [[C:%.*]]) {
100 ; CHECK-NEXT: [[TMP0:%.*]] = load i8, ptr [[A]], align 1
101 ; CHECK-NEXT: store i8 42, ptr [[C]], align 1
102 ; CHECK-NEXT: store i8 [[TMP0]], ptr [[B]], align 1
103 ; CHECK-NEXT: [[TMP1:%.*]] = load i8, ptr [[A]], align 1
104 ; CHECK-NEXT: ret i8 [[TMP1]]
107 %0 = load i8, ptr %a, align 1
108 store i8 42, ptr %c, align 1
109 store i8 %0, ptr %b, align 1
110 %1 = load i8, ptr %a, align 1
114 define i32 @test_unordered(ptr %a, ptr %b, ptr %c) {
115 ; CHECK-LABEL: define i32 @test_unordered(
116 ; CHECK-SAME: ptr [[A:%.*]], ptr [[B:%.*]], ptr [[C:%.*]]) {
118 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4
119 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[B]], align 4
120 ; CHECK-NEXT: [[TMP1:%.*]] = load atomic i32, ptr [[A]] unordered, align 4
121 ; CHECK-NEXT: ret i32 [[TMP1]]
124 %0 = load i32, ptr %a, align 4
125 store i32 %0, ptr %b, align 4
126 %1 = load atomic i32, ptr %a unordered, align 4