Skip to content

Commit 830df62

Browse files
committed
[ConstraintElimination] Add test from PR53123.
1 parent d27f022 commit 830df62

File tree

1 file changed

+34
-0
lines changed
  • llvm/test/Transforms/ConstraintElimination

1 file changed

+34
-0
lines changed

llvm/test/Transforms/ConstraintElimination/sub-nuw.ll

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,38 @@ if.end: ; preds = %entry
237237
ret void
238238
}
239239

240+
define i16 @test_pr53123_sub_constraint_sign(i16 %v) {
241+
; CHECK-LABEL: @test_pr53123_sub_constraint_sign(
242+
; CHECK-NEXT: bb.0:
243+
; CHECK-NEXT: [[SUB:%.*]] = sub nuw nsw i16 32767, [[V:%.*]]
244+
; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i16 [[V]], [[SUB]]
245+
; CHECK-NEXT: br i1 [[CMP1]], label [[BB_2:%.*]], label [[BB_1:%.*]]
246+
; CHECK: bb.1:
247+
; CHECK-NEXT: [[ADD:%.*]] = shl nuw nsw i16 [[V]], 1
248+
; CHECK-NEXT: [[SUB9:%.*]] = sub nuw nsw i16 32767, [[ADD]]
249+
; CHECK-NEXT: [[CMP11:%.*]] = icmp ugt i16 [[ADD]], [[SUB9]]
250+
; CHECK-NEXT: br i1 false, label [[BB_3:%.*]], label [[BB_2]]
251+
; CHECK: bb.2:
252+
; CHECK-NEXT: ret i16 1
253+
; CHECK: bb.3:
254+
; CHECK-NEXT: ret i16 0
255+
;
256+
bb.0:
257+
%sub = sub nuw nsw i16 32767, %v
258+
%cmp1 = icmp ugt i16 %v, %sub
259+
br i1 %cmp1, label %bb.2, label %bb.1
260+
261+
bb.1:
262+
%add = shl nuw nsw i16 %v, 1
263+
%sub9 = sub nuw nsw i16 32767, %add
264+
%cmp11 = icmp ugt i16 %add, %sub9
265+
br i1 %cmp11, label %bb.3, label %bb.2
266+
267+
bb.2:
268+
ret i16 1
269+
270+
bb.3:
271+
ret i16 0
272+
}
273+
240274
declare void @use(i1)

0 commit comments

Comments
 (0)