source: trunk/lib_ir/gen/llc_func_256.pytemplate.ll @ 4302

Last change on this file since 4302 was 4302, checked in by linmengl, 5 years ago

use template for 256-bit library test. Tested 256-bit long integer shift.

File size: 1.1 KB
Line 
1declare {i256, i1} @llvm.uadd.with.overflow.carryin.i256(i256 %a, i256 %b, i1 %carryin)
2
3define void @add_with_carry_ir_better(<4 x i64> %a, <4 x i64> %b, <4 x i64> %carry_in, <4 x i64>* %carry_out, <4 x i64>* %sum) {
4entry:
5  %aa = bitcast <4 x i64> %a to i256
6  %bb = bitcast <4 x i64> %b to i256
7  %cc = bitcast <4 x i64> %carry_in to i256
8  %cin = trunc i256 %cc to i1
9
10  %res1 = call {i256, i1} @llvm.uadd.with.overflow.carryin.i256(i256 %aa, i256 %bb, i1 %cin)
11  %sum1 = extractvalue {i256, i1} %res1, 0
12  %obit = extractvalue {i256, i1} %res1, 1
13
14  %ret_sum = bitcast i256 %sum1 to <4 x i64>
15  %obit_64 = zext i1 %obit to i64
16  %obit_2x64 = insertelement <4 x i64> zeroinitializer, i64 %obit_64, i32 0
17
18  store <4 x i64> %ret_sum, <4 x i64>* %sum
19  store <4 x i64> %obit_2x64, <4 x i64>* %carry_out
20
21  ret void
22}
23
24{% for sh in LongShiftAmount256 %}
25define <4 x i64> @long_shift_dslli_{{sh}}(<4 x i64> %a, <4 x i64> %b) {
26entry:
27  %aa = bitcast <4 x i64> %a to i256
28  %bb = bitcast <4 x i64> %b to i256
29
30  %c = shl i256 %aa, {{sh}}
31  %d = lshr i256 %bb, {{256 - sh}}
32  %e = or i256 %c, %d
33
34  %cc = bitcast i256 %e to <4 x i64>
35  ret <4 x i64> %cc
36}
37
38{% endfor %}
Note: See TracBrowser for help on using the repository browser.