1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=licm -S | FileCheck %s
4 declare void @maythrow()
7 define void @sdiv_not_ok(i16 %n, i16 %xx) {
8 ; CHECK-LABEL: @sdiv_not_ok(
10 ; CHECK-NEXT: [[X:%.*]] = or i16 [[XX:%.*]], 1
11 ; CHECK-NEXT: br label [[LOOP:%.*]]
13 ; CHECK-NEXT: call void @maythrow()
14 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i16 [[N:%.*]], [[X]]
15 ; CHECK-NEXT: call void @use(i16 [[DIV]])
16 ; CHECK-NEXT: br label [[LOOP]]
23 %div = sdiv i16 %n, %x
24 call void @use(i16 %div)
28 define void @srem_not_ok2(i16 %nn, i16 %x) {
29 ; CHECK-LABEL: @srem_not_ok2(
31 ; CHECK-NEXT: [[N:%.*]] = and i16 [[NN:%.*]], 1323
32 ; CHECK-NEXT: br label [[LOOP:%.*]]
34 ; CHECK-NEXT: call void @maythrow()
35 ; CHECK-NEXT: [[DIV:%.*]] = srem i16 [[N]], [[X:%.*]]
36 ; CHECK-NEXT: call void @use(i16 [[DIV]])
37 ; CHECK-NEXT: br label [[LOOP]]
40 %n = and i16 %nn, 1323
44 %div = srem i16 %n, %x
45 call void @use(i16 %div)
49 define void @sdiv_ok(i16 %n, i16 %xx) {
50 ; CHECK-LABEL: @sdiv_ok(
52 ; CHECK-NEXT: [[XO:%.*]] = or i16 [[XX:%.*]], 1
53 ; CHECK-NEXT: [[X:%.*]] = and i16 [[XO]], 123
54 ; CHECK-NEXT: br label [[LOOP:%.*]]
56 ; CHECK-NEXT: call void @maythrow()
57 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i16 [[N:%.*]], [[X]]
58 ; CHECK-NEXT: call void @use(i16 [[DIV]])
59 ; CHECK-NEXT: br label [[LOOP]]
67 %div = sdiv i16 %n, %x
68 call void @use(i16 %div)
72 define void @srem_ok2(i16 %nn, i16 %xx) {
73 ; CHECK-LABEL: @srem_ok2(
75 ; CHECK-NEXT: [[N:%.*]] = and i16 [[NN:%.*]], 123
76 ; CHECK-NEXT: [[X:%.*]] = or i16 [[XX:%.*]], 1
77 ; CHECK-NEXT: br label [[LOOP:%.*]]
79 ; CHECK-NEXT: call void @maythrow()
80 ; CHECK-NEXT: [[DIV:%.*]] = srem i16 [[N]], [[X]]
81 ; CHECK-NEXT: call void @use(i16 [[DIV]])
82 ; CHECK-NEXT: br label [[LOOP]]
90 %div = srem i16 %n, %x
91 call void @use(i16 %div)
95 define void @udiv_not_ok(i16 %n, i16 %xx) {
96 ; CHECK-LABEL: @udiv_not_ok(
98 ; CHECK-NEXT: [[X:%.*]] = xor i16 [[XX:%.*]], 1
99 ; CHECK-NEXT: br label [[LOOP:%.*]]
101 ; CHECK-NEXT: call void @maythrow()
102 ; CHECK-NEXT: [[DIV:%.*]] = udiv i16 [[N:%.*]], [[X]]
103 ; CHECK-NEXT: call void @use(i16 [[DIV]])
104 ; CHECK-NEXT: br label [[LOOP]]
110 call void @maythrow()
111 %div = udiv i16 %n, %x
112 call void @use(i16 %div)
116 define void @udiv_ok(i16 %n, i16 %xx) {
117 ; CHECK-LABEL: @udiv_ok(
119 ; CHECK-NEXT: [[X:%.*]] = or i16 [[XX:%.*]], 1
120 ; CHECK-NEXT: br label [[LOOP:%.*]]
122 ; CHECK-NEXT: call void @maythrow()
123 ; CHECK-NEXT: [[DIV:%.*]] = udiv i16 [[N:%.*]], [[X]]
124 ; CHECK-NEXT: call void @use(i16 [[DIV]])
125 ; CHECK-NEXT: br label [[LOOP]]
131 call void @maythrow()
132 %div = udiv i16 %n, %x
133 call void @use(i16 %div)