freeze.ll
1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
define i32 @fold(i32 %x) {
; CHECK-LABEL: @fold(
; CHECK-NEXT: [[Y:%.*]] = freeze i32 [[X:%.*]]
; CHECK-NEXT: ret i32 [[Y]]
;
%y = freeze i32 %x
%z = freeze i32 %y
ret i32 %z
}
define i32 @make_const() {
; CHECK-LABEL: @make_const(
; CHECK-NEXT: ret i32 10
;
%x = freeze i32 10
ret i32 %x
}
define i32 @and_freeze_undef(i32 %x) {
; CHECK-LABEL: @and_freeze_undef(
; CHECK-NEXT: ret i32 0
;
%f = freeze i32 undef
%res = and i32 %x, %f
ret i32 %res
}
declare void @use_i32(i32)
define i32 @and_freeze_undef_multipleuses(i32 %x) {
; CHECK-LABEL: @and_freeze_undef_multipleuses(
; CHECK-NEXT: call void @use_i32(i32 0)
; CHECK-NEXT: ret i32 0
;
%f = freeze i32 undef
%res = and i32 %x, %f
call void @use_i32(i32 %f)
ret i32 %res
}
define i32 @or_freeze_undef(i32 %x) {
; CHECK-LABEL: @or_freeze_undef(
; CHECK-NEXT: ret i32 -1
;
%f = freeze i32 undef
%res = or i32 %x, %f
ret i32 %res
}
define i32 @or_freeze_undef_multipleuses(i32 %x) {
; CHECK-LABEL: @or_freeze_undef_multipleuses(
; CHECK-NEXT: call void @use_i32(i32 0)
; CHECK-NEXT: ret i32 [[X:%.*]]
;
%f = freeze i32 undef
%res = or i32 %x, %f
call void @use_i32(i32 %f)
ret i32 %res
}
declare void @use_i32_i1(i32, i1)
define void @or_select_multipleuses(i32 %x, i1 %y) {
; CHECK-LABEL: @or_select_multipleuses(
; CHECK-NEXT: call void @use_i32_i1(i32 32, i1 [[Y:%.*]])
; CHECK-NEXT: ret void
;
%f = freeze i1 undef
%a = select i1 %f, i32 %x, i32 32 ; prefers %f to be false
%b = or i1 %f, %y ; prefers %f to be true
call void @use_i32_i1(i32 %a, i1 %b)
ret void
}