1 ; RUN: opt < %s -gvn -S | FileCheck %s
3 ; 32-bit little endian target.
4 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
7 define i32 @test0(i32 %V, i32* %P) {
16 ;;===----------------------------------------------------------------------===;;
17 ;; Store -> Load and Load -> Load forwarding where src and dst are different
18 ;; types, but where the base pointer is a must alias.
19 ;;===----------------------------------------------------------------------===;;
21 ;; i32 -> f32 forwarding.
22 define float @coerce_mustalias1(i32 %V, i32* %P) {
25 %P2 = bitcast i32* %P to float*
29 ; CHECK: @coerce_mustalias1
34 ;; i32* -> float forwarding.
35 define float @coerce_mustalias2(i32* %V, i32** %P) {
36 store i32* %V, i32** %P
38 %P2 = bitcast i32** %P to float*
42 ; CHECK: @coerce_mustalias2
47 ;; float -> i32* forwarding.
48 define i32* @coerce_mustalias3(float %V, float* %P) {
49 store float %V, float* %P
51 %P2 = bitcast float* %P to i32**
55 ; CHECK: @coerce_mustalias3
60 ;; i32 -> f32 load forwarding.
61 define float @coerce_mustalias4(i32* %P, i1 %cond) {
64 %P2 = bitcast i32* %P to float*
66 br i1 %cond, label %T, label %F
71 %X = bitcast i32 %A to float
74 ; CHECK: @coerce_mustalias4
75 ; CHECK: %A = load i32* %P
81 ;; i32 -> i8 forwarding
82 define i8 @coerce_mustalias5(i32 %V, i32* %P) {
85 %P2 = bitcast i32* %P to i8*
89 ; CHECK: @coerce_mustalias5
94 ;; i64 -> float forwarding
95 define float @coerce_mustalias6(i64 %V, i64* %P) {
98 %P2 = bitcast i64* %P to float*
102 ; CHECK: @coerce_mustalias6
107 ;; i64 -> i8* (32-bit) forwarding
108 define i8* @coerce_mustalias7(i64 %V, i64* %P) {
109 store i64 %V, i64* %P
111 %P2 = bitcast i64* %P to i8**
115 ; CHECK: @coerce_mustalias7
120 ;; non-local i32/float -> i8 load forwarding.
121 define i8 @coerce_mustalias_nonlocal0(i32* %P, i1 %cond) {
122 %P2 = bitcast i32* %P to float*
123 %P3 = bitcast i32* %P to i8*
124 br i1 %cond, label %T, label %F
126 store i32 42, i32* %P
130 store float 1.0, float* %P2
137 ; CHECK: @coerce_mustalias_nonlocal0
139 ; CHECK: %A = phi i8 [
144 ;; non-local i32 -> i8 partial redundancy load forwarding.
145 define i8 @coerce_mustalias_pre0(i32* %P, i1 %cond) {
146 %P3 = bitcast i32* %P to i8*
147 br i1 %cond, label %T, label %F
149 store i32 42, i32* %P
159 ; CHECK: @coerce_mustalias_pre0
161 ; CHECK: load i8* %P3
163 ; CHECK: %A = phi i8 [