• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -debugify -instcombine -S | FileCheck %s
2
3declare void @escape32(i32)
4
5define i64 @test_sext_zext(i16 %A) {
6; CHECK-LABEL: @test_sext_zext(
7; CHECK-NEXT:  [[C2:%.*]] = zext i16 %A to i64
8; CHECK-NEXT:  call void @llvm.dbg.value(metadata i64 [[C2]], {{.*}}, metadata !DIExpression())
9; CHECK-NEXT:  call void @llvm.dbg.value(metadata i64 [[C2]], {{.*}}, metadata !DIExpression())
10  %c1 = zext i16 %A to i32
11  %c2 = sext i32 %c1 to i64
12  ret i64 %c2
13}
14
15define i64 @test_used_sext_zext(i16 %A) {
16; CHECK-LABEL: @test_used_sext_zext(
17; CHECK-NEXT:  [[C1:%.*]] = zext i16 %A to i32
18; CHECK-NEXT:  call void @llvm.dbg.value(metadata i32 [[C1]], {{.*}}, metadata !DIExpression())
19; CHECK-NEXT:  [[C2:%.*]] = zext i16 %A to i64
20; CHECK-NEXT:  call void @llvm.dbg.value(metadata i64 [[C2]], {{.*}}, metadata !DIExpression())
21; CHECK-NEXT:  call void @escape32(i32 %c1)
22; CHECK-NEXT:  ret i64 %c2
23  %c1 = zext i16 %A to i32
24  %c2 = sext i32 %c1 to i64
25  call void @escape32(i32 %c1)
26  ret i64 %c2
27}
28
29define i32 @test_cast_select(i1 %cond) {
30; CHECK-LABEL: @test_cast_select(
31; CHECK-NEXT:  [[sel:%.*]] = select i1 %cond, i32 3, i32 5
32; CHECK-NEXT:  call void @llvm.dbg.value(metadata i32 [[sel]], {{.*}}, metadata !DIExpression())
33; CHECK-NEXT:  call void @llvm.dbg.value(metadata i32 [[sel]], {{.*}}, metadata !DIExpression())
34; CHECK-NEXT:  ret i32 [[sel]]
35  %sel = select i1 %cond, i16 3, i16 5
36  %cast = zext i16 %sel to i32
37  ret i32 %cast
38}
39
40define void @test_or(i64 %A) {
41; CHECK-LABEL: @test_or(
42; CHECK-NEXT:  call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 256, DW_OP_or, DW_OP_stack_value))
43  %1 = or i64 %A, 256
44  ret void
45}
46
47define void @test_xor(i32 %A) {
48; CHECK-LABEL: @test_xor(
49; CHECK-NEXT:  call void @llvm.dbg.value(metadata i32 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 1, DW_OP_xor, DW_OP_stack_value))
50  %1 = xor i32 %A, 1
51  ret void
52}
53
54define void @test_sub_neg(i64 %A) {
55; CHECK-LABEL: @test_sub_neg(
56; CHECK-NEXT:  call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_plus_uconst, 1, DW_OP_stack_value))
57  %1 = sub i64 %A, -1
58  ret void
59}
60
61define void @test_sub_pos(i64 %A) {
62; CHECK-LABEL: @test_sub_pos(
63; CHECK-NEXT:  call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 1, DW_OP_minus, DW_OP_stack_value))
64  %1 = sub i64 %A, 1
65  ret void
66}
67
68define void @test_shl(i64 %A) {
69; CHECK-LABEL: @test_shl(
70; CHECK-NEXT:  call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shl, DW_OP_stack_value))
71  %1 = shl i64 %A, 7
72  ret void
73}
74
75define void @test_lshr(i64 %A) {
76; CHECK-LABEL: @test_lshr(
77; CHECK-NEXT:  call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shr, DW_OP_stack_value))
78  %1 = lshr i64 %A, 7
79  ret void
80}
81
82define void @test_ashr(i64 %A) {
83; CHECK-LABEL: @test_ashr(
84; CHECK-NEXT:  call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shra, DW_OP_stack_value))
85  %1 = ashr i64 %A, 7
86  ret void
87}
88
89define void @test_mul(i64 %A) {
90; CHECK-LABEL: @test_mul(
91; CHECK-NEXT:  call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_mul, DW_OP_stack_value))
92  %1 = mul i64 %A, 7
93  ret void
94}
95
96define void @test_sdiv(i64 %A) {
97; CHECK-LABEL: @test_sdiv(
98; CHECK-NEXT:  call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_div, DW_OP_stack_value))
99  %1 = sdiv i64 %A, 7
100  ret void
101}
102
103define void @test_srem(i64 %A) {
104; CHECK-LABEL: @test_srem(
105; CHECK-NEXT:  call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_mod, DW_OP_stack_value))
106  %1 = srem i64 %A, 7
107  ret void
108}
109
110define void @test_ptrtoint(i64* %P) {
111; CHECK-LABEL: @test_ptrtoint
112; CHECK-NEXT:  call void @llvm.dbg.value(metadata i64* %P, {{.*}}, metadata !DIExpression())
113  %1 = ptrtoint i64* %P to i64
114  ret void
115}
116
117define void @test_and(i64 %A) {
118; CHECK-LABEL: @test_and(
119; CHECK-NEXT:  call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 256, DW_OP_and, DW_OP_stack_value))
120  %1 = and i64 %A, 256
121  ret void
122}
123