Skip to content

Commit

Permalink
[InstCombine][NFC] reuse-constant-from-select-in-icmp.ll - revisit tests
Browse files Browse the repository at this point in the history
llvm-svn: 369839
  • Loading branch information
LebedevRI committed Aug 24, 2019
1 parent 62083ec commit b3eccc7
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ define i32 @n21_equality(i32 %x, i32 %y) {
ret i32 %r
}

; We don't touch sign checks
define i32 @n22_sign_check(i32 %x, i32 %y) {
; CHECK-LABEL: @n22_sign_check(
; There is nothing special about sign-bit-tests, we can fold them.
define i32 @t22_sign_check(i32 %x, i32 %y) {
; CHECK-LABEL: @t22_sign_check(
; CHECK-NEXT: [[T:%.*]] = icmp slt i32 [[X:%.*]], 0
; CHECK-NEXT: [[R:%.*]] = select i1 [[T]], i32 -1, i32 [[Y:%.*]]
; CHECK-NEXT: ret i32 [[R]]
Expand All @@ -274,6 +274,16 @@ define i32 @n22_sign_check(i32 %x, i32 %y) {
%r = select i1 %t, i32 -1, i32 %y
ret i32 %r
}
define i32 @t22_sign_check2(i32 %x, i32 %y) {
; CHECK-LABEL: @t22_sign_check2(
; CHECK-NEXT: [[T:%.*]] = icmp sgt i32 [[X:%.*]], -1
; CHECK-NEXT: [[R:%.*]] = select i1 [[T]], i32 0, i32 [[Y:%.*]]
; CHECK-NEXT: ret i32 [[R]]
;
%t = icmp sgt i32 %x, -1
%r = select i1 %t, i32 0, i32 %y
ret i32 %r
}

; If the types don't match we currently don't do anything.
define i32 @n23_type_mismatch(i64 %x, i32 %y) {
Expand Down

0 comments on commit b3eccc7

Please sign in to comment.