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