[InstCombine] add nnan tests; NFC

As suggested in D37427, we could have a value tracking function and folds that use
it to simplify these cases. 

llvm-svn: 312578
This commit is contained in:
Sanjay Patel 2017-09-05 21:20:35 +00:00
parent 2ea27186b4
commit 18e126e5d4
1 changed files with 30 additions and 0 deletions

View File

@ -144,3 +144,33 @@ define <2 x i1> @uno_vec_with_nan(<2 x double> %x) {
ret <2 x i1> %f
}
; TODO: This could be handled in InstSimplify.
define i1 @nnan_ops_to_fcmp_ord(float %x, float %y) {
; CHECK-LABEL: @nnan_ops_to_fcmp_ord(
; CHECK-NEXT: [[MUL:%.*]] = fmul nnan float %x, %y
; CHECK-NEXT: [[DIV:%.*]] = fdiv nnan float %x, %y
; CHECK-NEXT: [[CMP:%.*]] = fcmp ord float [[MUL]], [[DIV]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%mul = fmul nnan float %x, %y
%div = fdiv nnan float %x, %y
%cmp = fcmp ord float %mul, %div
ret i1 %cmp
}
; TODO: This could be handled in InstSimplify.
define i1 @nnan_ops_to_fcmp_uno(float %x, float %y) {
; CHECK-LABEL: @nnan_ops_to_fcmp_uno(
; CHECK-NEXT: [[MUL:%.*]] = fmul nnan float %x, %y
; CHECK-NEXT: [[DIV:%.*]] = fdiv nnan float %x, %y
; CHECK-NEXT: [[CMP:%.*]] = fcmp uno float [[MUL]], [[DIV]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%mul = fmul nnan float %x, %y
%div = fdiv nnan float %x, %y
%cmp = fcmp uno float %mul, %div
ret i1 %cmp
}