Skip to content

Commit 52a3983

Browse files
committed
[ConstraintElim] Add tests for regression
1 parent 7bbf801 commit 52a3983

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

llvm/test/Transforms/ConstraintElimination/shr-exact.ll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,25 @@ entry:
174174
%cmp = icmp slt i64 %x, %y
175175
ret i1 %cmp
176176
}
177+
178+
; Regression: After converting (ashr X, 3) u> 4 to X u> 32, we should still
179+
; be able to use the original condition to simplify icmp with ashr.
180+
define i1 @precond_icmp_ashr_and_constant_regression(i64 %x) {
181+
; CHECK-LABEL: define i1 @precond_icmp_ashr_and_constant_regression(
182+
; CHECK-SAME: i64 [[X:%.*]]) {
183+
; CHECK-NEXT: [[ENTRY:.*:]]
184+
; CHECK-NEXT: [[ASHR:%.*]] = ashr exact i64 [[X]], 3
185+
; CHECK-NEXT: [[COND:%.*]] = icmp ugt i64 [[ASHR]], 4
186+
; CHECK-NEXT: call void @llvm.assume(i1 [[COND]])
187+
; CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[ASHR]], -1
188+
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[ADD]], 0
189+
; CHECK-NEXT: ret i1 [[CMP]]
190+
;
191+
entry:
192+
%ashr = ashr exact i64 %x, 3
193+
%cond = icmp ugt i64 %ashr, 4
194+
call void @llvm.assume(i1 %cond)
195+
%add = add nsw i64 %ashr, -1
196+
%cmp = icmp eq i64 %add, 0
197+
ret i1 %cmp
198+
}

0 commit comments

Comments
 (0)