1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -instcombine -S < %s | FileCheck %s
4 define float @matching_scalar(<4 x float>* dereferenceable(16) %p) {
5 ; CHECK-LABEL: @matching_scalar(
6 ; CHECK-NEXT: [[BC:%.*]] = getelementptr inbounds <4 x float>, <4 x float>* [[P:%.*]], i64 0, i64 0
7 ; CHECK-NEXT: [[R:%.*]] = load float, float* [[BC]], align 16
8 ; CHECK-NEXT: ret float [[R]]
10 %bc = bitcast <4 x float>* %p to float*
11 %r = load float, float* %bc, align 16
15 define i32 @nonmatching_scalar(<4 x float>* dereferenceable(16) %p) {
16 ; CHECK-LABEL: @nonmatching_scalar(
17 ; CHECK-NEXT: [[BC:%.*]] = bitcast <4 x float>* [[P:%.*]] to i32*
18 ; CHECK-NEXT: [[R:%.*]] = load i32, i32* [[BC]], align 16
19 ; CHECK-NEXT: ret i32 [[R]]
21 %bc = bitcast <4 x float>* %p to i32*
22 %r = load i32, i32* %bc, align 16
26 define i64 @larger_scalar(<4 x float>* dereferenceable(16) %p) {
27 ; CHECK-LABEL: @larger_scalar(
28 ; CHECK-NEXT: [[BC:%.*]] = bitcast <4 x float>* [[P:%.*]] to i64*
29 ; CHECK-NEXT: [[R:%.*]] = load i64, i64* [[BC]], align 16
30 ; CHECK-NEXT: ret i64 [[R]]
32 %bc = bitcast <4 x float>* %p to i64*
33 %r = load i64, i64* %bc, align 16
37 define i8 @smaller_scalar(<4 x float>* dereferenceable(16) %p) {
38 ; CHECK-LABEL: @smaller_scalar(
39 ; CHECK-NEXT: [[BC:%.*]] = bitcast <4 x float>* [[P:%.*]] to i8*
40 ; CHECK-NEXT: [[R:%.*]] = load i8, i8* [[BC]], align 16
41 ; CHECK-NEXT: ret i8 [[R]]
43 %bc = bitcast <4 x float>* %p to i8*
44 %r = load i8, i8* %bc, align 16
48 define i8 @smaller_scalar_less_aligned(<4 x float>* dereferenceable(16) %p) {
49 ; CHECK-LABEL: @smaller_scalar_less_aligned(
50 ; CHECK-NEXT: [[BC:%.*]] = bitcast <4 x float>* [[P:%.*]] to i8*
51 ; CHECK-NEXT: [[R:%.*]] = load i8, i8* [[BC]], align 4
52 ; CHECK-NEXT: ret i8 [[R]]
54 %bc = bitcast <4 x float>* %p to i8*
55 %r = load i8, i8* %bc, align 4
59 define float @matching_scalar_small_deref(<4 x float>* dereferenceable(15) %p) {
60 ; CHECK-LABEL: @matching_scalar_small_deref(
61 ; CHECK-NEXT: [[BC:%.*]] = getelementptr inbounds <4 x float>, <4 x float>* [[P:%.*]], i64 0, i64 0
62 ; CHECK-NEXT: [[R:%.*]] = load float, float* [[BC]], align 16
63 ; CHECK-NEXT: ret float [[R]]
65 %bc = bitcast <4 x float>* %p to float*
66 %r = load float, float* %bc, align 16
70 define float @matching_scalar_volatile(<4 x float>* dereferenceable(16) %p) {
71 ; CHECK-LABEL: @matching_scalar_volatile(
72 ; CHECK-NEXT: [[BC:%.*]] = getelementptr inbounds <4 x float>, <4 x float>* [[P:%.*]], i64 0, i64 0
73 ; CHECK-NEXT: [[R:%.*]] = load volatile float, float* [[BC]], align 16
74 ; CHECK-NEXT: ret float [[R]]
76 %bc = bitcast <4 x float>* %p to float*
77 %r = load volatile float, float* %bc, align 16
81 define float @nonvector(double* dereferenceable(16) %p) {
82 ; CHECK-LABEL: @nonvector(
83 ; CHECK-NEXT: [[BC:%.*]] = bitcast double* [[P:%.*]] to float*
84 ; CHECK-NEXT: [[R:%.*]] = load float, float* [[BC]], align 16
85 ; CHECK-NEXT: ret float [[R]]
87 %bc = bitcast double* %p to float*
88 %r = load float, float* %bc, align 16