• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -instcombine -S | FileCheck %s
2
3; This turns into a&1 != 0
4define <2 x i1> @test1(<2 x i64> %a) {
5  %t = trunc <2 x i64> %a to <2 x i1>
6  ret <2 x i1> %t
7
8; CHECK: @test1
9; CHECK:   and <2 x i64> %a, <i64 1, i64 1>
10; CHECK:   icmp ne <2 x i64> %1, zeroinitializer
11}
12
13; The ashr turns into an lshr.
14define <2 x i64> @test2(<2 x i64> %a) {
15  %b = and <2 x i64> %a, <i64 65535, i64 65535>
16  %t = ashr <2 x i64> %b, <i64 1, i64 1>
17  ret <2 x i64> %t
18
19; CHECK: @test2
20; CHECK:   and <2 x i64> %a, <i64 65535, i64 65535>
21; CHECK:   lshr <2 x i64> %b, <i64 1, i64 1>
22}
23
24
25
26define <2 x i64> @test3(<4 x float> %a, <4 x float> %b) nounwind readnone {
27entry:
28	%cmp = fcmp ord <4 x float> %a, zeroinitializer
29	%sext = sext <4 x i1> %cmp to <4 x i32>
30	%cmp4 = fcmp ord <4 x float> %b, zeroinitializer
31	%sext5 = sext <4 x i1> %cmp4 to <4 x i32>
32	%and = and <4 x i32> %sext, %sext5
33	%conv = bitcast <4 x i32> %and to <2 x i64>
34	ret <2 x i64> %conv
35
36; CHECK: @test3
37; CHECK:   fcmp ord <4 x float> %a, %b
38}
39
40define <2 x i64> @test4(<4 x float> %a, <4 x float> %b) nounwind readnone {
41entry:
42	%cmp = fcmp uno <4 x float> %a, zeroinitializer
43	%sext = sext <4 x i1> %cmp to <4 x i32>
44	%cmp4 = fcmp uno <4 x float> %b, zeroinitializer
45	%sext5 = sext <4 x i1> %cmp4 to <4 x i32>
46	%or = or <4 x i32> %sext, %sext5
47	%conv = bitcast <4 x i32> %or to <2 x i64>
48	ret <2 x i64> %conv
49; CHECK: @test4
50; CHECK:   fcmp uno <4 x float> %a, %b
51}
52
53
54; rdar://7434900
55define <2 x i64> @test5(<4 x float> %a, <4 x float> %b) nounwind readnone {
56entry:
57	%cmp = fcmp ult <4 x float> %a, zeroinitializer
58	%sext = sext <4 x i1> %cmp to <4 x i32>
59	%cmp4 = fcmp ult <4 x float> %b, zeroinitializer
60	%sext5 = sext <4 x i1> %cmp4 to <4 x i32>
61	%and = and <4 x i32> %sext, %sext5
62	%conv = bitcast <4 x i32> %and to <2 x i64>
63	ret <2 x i64> %conv
64
65; CHECK: @test5
66; CHECK:   sext <4 x i1> %cmp to <4 x i32>
67; CHECK:   sext <4 x i1> %cmp4 to <4 x i32>
68}
69
70
71define void @convert(<2 x i32>* %dst.addr, <2 x i64> %src) nounwind {
72entry:
73  %val = trunc <2 x i64> %src to <2 x i32>
74  %add = add <2 x i32> %val, <i32 1, i32 1>
75  store <2 x i32> %add, <2 x i32>* %dst.addr
76  ret void
77}
78
79define <2 x i65> @foo(<2 x i64> %t) {
80  %a = trunc <2 x i64> %t to <2 x i32>
81  %b = zext <2 x i32> %a to <2 x i65>
82  ret <2 x i65> %b
83}
84define <2 x i64> @bar(<2 x i65> %t) {
85  %a = trunc <2 x i65> %t to <2 x i32>
86  %b = zext <2 x i32> %a to <2 x i64>
87  ret <2 x i64> %b
88}
89define <2 x i65> @foos(<2 x i64> %t) {
90  %a = trunc <2 x i64> %t to <2 x i32>
91  %b = sext <2 x i32> %a to <2 x i65>
92  ret <2 x i65> %b
93}
94define <2 x i64> @bars(<2 x i65> %t) {
95  %a = trunc <2 x i65> %t to <2 x i32>
96  %b = sext <2 x i32> %a to <2 x i64>
97  ret <2 x i64> %b
98}
99define <2 x i64> @quxs(<2 x i64> %t) {
100  %a = trunc <2 x i64> %t to <2 x i32>
101  %b = sext <2 x i32> %a to <2 x i64>
102  ret <2 x i64> %b
103}
104define <2 x i64> @quxt(<2 x i64> %t) {
105  %a = shl <2 x i64> %t, <i64 32, i64 32>
106  %b = ashr <2 x i64> %a, <i64 32, i64 32>
107  ret <2 x i64> %b
108}
109define <2 x double> @fa(<2 x double> %t) {
110  %a = fptrunc <2 x double> %t to <2 x float>
111  %b = fpext <2 x float> %a to <2 x double>
112  ret <2 x double> %b
113}
114define <2 x double> @fb(<2 x double> %t) {
115  %a = fptoui <2 x double> %t to <2 x i64>
116  %b = uitofp <2 x i64> %a to <2 x double>
117  ret <2 x double> %b
118}
119define <2 x double> @fc(<2 x double> %t) {
120  %a = fptosi <2 x double> %t to <2 x i64>
121  %b = sitofp <2 x i64> %a to <2 x double>
122  ret <2 x double> %b
123}
124
125; PR9228
126; This was a crasher, so no CHECK statements.
127define <4 x float> @f(i32 %a) nounwind alwaysinline {
128; CHECK: @f
129entry:
130  %dim = insertelement <4 x i32> undef, i32 %a, i32 0
131  %dim30 = insertelement <4 x i32> %dim, i32 %a, i32 1
132  %dim31 = insertelement <4 x i32> %dim30, i32 %a, i32 2
133  %dim32 = insertelement <4 x i32> %dim31, i32 %a, i32 3
134
135  %offset_ptr = getelementptr <4 x float>* null, i32 1
136  %offset_int = ptrtoint <4 x float>* %offset_ptr to i64
137  %sizeof32 = trunc i64 %offset_int to i32
138
139  %smearinsert33 = insertelement <4 x i32> undef, i32 %sizeof32, i32 0
140  %smearinsert34 = insertelement <4 x i32> %smearinsert33, i32 %sizeof32, i32 1
141  %smearinsert35 = insertelement <4 x i32> %smearinsert34, i32 %sizeof32, i32 2
142  %smearinsert36 = insertelement <4 x i32> %smearinsert35, i32 %sizeof32, i32 3
143
144  %delta_scale = mul <4 x i32> %dim32, %smearinsert36
145  %offset_delta = add <4 x i32> zeroinitializer, %delta_scale
146
147  %offset_varying_delta = add <4 x i32> %offset_delta, undef
148
149  ret <4 x float> undef
150}
151
152