1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -instcombine -S < %s | FileCheck %s
3 target datalayout = "E-p:64:64:64-p1:64:64:64-p2:32:32:32-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
5 @x = external global <2 x i64>, align 16
6 @xx = external global [13 x <2 x i64>], align 16
8 @x.as2 = external addrspace(2) global <2 x i64>, align 16
10 define <2 x i64> @static_hem() {
11 ; CHECK-LABEL: @static_hem(
12 ; CHECK-NEXT: [[TMP1:%.*]] = load <2 x i64>, <2 x i64>* getelementptr (<2 x i64>, <2 x i64>* @x, i64 7), align 16
13 ; CHECK-NEXT: ret <2 x i64> [[TMP1]]
15 %t = getelementptr <2 x i64>, <2 x i64>* @x, i32 7
16 %tmp1 = load <2 x i64>, <2 x i64>* %t, align 1
20 define <2 x i64> @hem(i32 %i) {
22 ; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[I:%.*]] to i64
23 ; CHECK-NEXT: [[T:%.*]] = getelementptr <2 x i64>, <2 x i64>* @x, i64 [[TMP1]]
24 ; CHECK-NEXT: [[TMP1:%.*]] = load <2 x i64>, <2 x i64>* [[T]], align 16
25 ; CHECK-NEXT: ret <2 x i64> [[TMP1]]
27 %t = getelementptr <2 x i64>, <2 x i64>* @x, i32 %i
28 %tmp1 = load <2 x i64>, <2 x i64>* %t, align 1
32 define <2 x i64> @hem_2d(i32 %i, i32 %j) {
33 ; CHECK-LABEL: @hem_2d(
34 ; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[I:%.*]] to i64
35 ; CHECK-NEXT: [[TMP2:%.*]] = sext i32 [[J:%.*]] to i64
36 ; CHECK-NEXT: [[T:%.*]] = getelementptr [13 x <2 x i64>], [13 x <2 x i64>]* @xx, i64 [[TMP1]], i64 [[TMP2]]
37 ; CHECK-NEXT: [[TMP1:%.*]] = load <2 x i64>, <2 x i64>* [[T]], align 16
38 ; CHECK-NEXT: ret <2 x i64> [[TMP1]]
40 %t = getelementptr [13 x <2 x i64>], [13 x <2 x i64>]* @xx, i32 %i, i32 %j
41 %tmp1 = load <2 x i64>, <2 x i64>* %t, align 1
45 define <2 x i64> @foo() {
47 ; CHECK-NEXT: [[TMP1:%.*]] = load <2 x i64>, <2 x i64>* @x, align 16
48 ; CHECK-NEXT: ret <2 x i64> [[TMP1]]
50 %tmp1 = load <2 x i64>, <2 x i64>* @x, align 1
54 define <2 x i64> @bar() {
56 ; CHECK-NEXT: [[T:%.*]] = alloca <2 x i64>, align 16
57 ; CHECK-NEXT: call void @kip(<2 x i64>* nonnull [[T]])
58 ; CHECK-NEXT: [[TMP1:%.*]] = load <2 x i64>, <2 x i64>* [[T]], align 16
59 ; CHECK-NEXT: ret <2 x i64> [[TMP1]]
62 call void @kip(<2 x i64>* %t)
63 %tmp1 = load <2 x i64>, <2 x i64>* %t, align 1
67 define void @static_hem_store(<2 x i64> %y) {
68 ; CHECK-LABEL: @static_hem_store(
69 ; CHECK-NEXT: store <2 x i64> [[Y:%.*]], <2 x i64>* getelementptr (<2 x i64>, <2 x i64>* @x, i64 7), align 16
70 ; CHECK-NEXT: ret void
72 %t = getelementptr <2 x i64>, <2 x i64>* @x, i32 7
73 store <2 x i64> %y, <2 x i64>* %t, align 1
77 define void @hem_store(i32 %i, <2 x i64> %y) {
78 ; CHECK-LABEL: @hem_store(
79 ; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[I:%.*]] to i64
80 ; CHECK-NEXT: [[T:%.*]] = getelementptr <2 x i64>, <2 x i64>* @x, i64 [[TMP1]]
81 ; CHECK-NEXT: store <2 x i64> [[Y:%.*]], <2 x i64>* [[T]], align 16
82 ; CHECK-NEXT: ret void
84 %t = getelementptr <2 x i64>, <2 x i64>* @x, i32 %i
85 store <2 x i64> %y, <2 x i64>* %t, align 1
89 define void @hem_2d_store(i32 %i, i32 %j, <2 x i64> %y) {
90 ; CHECK-LABEL: @hem_2d_store(
91 ; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[I:%.*]] to i64
92 ; CHECK-NEXT: [[TMP2:%.*]] = sext i32 [[J:%.*]] to i64
93 ; CHECK-NEXT: [[T:%.*]] = getelementptr [13 x <2 x i64>], [13 x <2 x i64>]* @xx, i64 [[TMP1]], i64 [[TMP2]]
94 ; CHECK-NEXT: store <2 x i64> [[Y:%.*]], <2 x i64>* [[T]], align 16
95 ; CHECK-NEXT: ret void
97 %t = getelementptr [13 x <2 x i64>], [13 x <2 x i64>]* @xx, i32 %i, i32 %j
98 store <2 x i64> %y, <2 x i64>* %t, align 1
102 define void @foo_store(<2 x i64> %y) {
103 ; CHECK-LABEL: @foo_store(
104 ; CHECK-NEXT: store <2 x i64> [[Y:%.*]], <2 x i64>* @x, align 16
105 ; CHECK-NEXT: ret void
107 store <2 x i64> %y, <2 x i64>* @x, align 1
111 define void @bar_store(<2 x i64> %y) {
112 ; CHECK-LABEL: @bar_store(
113 ; CHECK-NEXT: [[T:%.*]] = alloca <2 x i64>, align 16
114 ; CHECK-NEXT: call void @kip(<2 x i64>* nonnull [[T]])
115 ; CHECK-NEXT: store <2 x i64> [[Y:%.*]], <2 x i64>* [[T]], align 16
116 ; CHECK-NEXT: ret void
118 %t = alloca <2 x i64>
119 call void @kip(<2 x i64>* %t)
120 store <2 x i64> %y, <2 x i64>* %t, align 1
124 declare void @kip(<2 x i64>* %t)