[InstCombine] peek through fabs() when checking isnan()

That should be the end of the missing cases for this fold.
See earlier patches in this series:
rL346321
rL346324

llvm-svn: 346327
This commit is contained in:
Sanjay Patel 2018-11-07 15:44:26 +00:00
parent 35dfce723c
commit bb521e63af
2 changed files with 8 additions and 5 deletions

View File

@ -5328,8 +5328,13 @@ static Instruction *foldFabsWithFcmpZero(FCmpInst &I) {
case FCmpInst::FCMP_UEQ:
case FCmpInst::FCMP_ONE:
case FCmpInst::FCMP_UNE:
// fabs(X) == 0.0 --> X == 0.0
case FCmpInst::FCMP_ORD:
case FCmpInst::FCMP_UNO:
// Look through the fabs() because it doesn't change anything but the sign.
// fabs(X) == 0.0 --> X == 0.0,
// fabs(X) != 0.0 --> X != 0.0
// isnan(fabs(X)) --> isnan(X)
// !isnan(fabs(X) --> !isnan(X)
return new FCmpInst(I.getPredicate(), X, I.getOperand(1));
default:

View File

@ -298,8 +298,7 @@ define <2 x i1> @fabs_ueq(<2 x float> %a) {
define <2 x i1> @fabs_ord(<2 x float> %a) {
; CHECK-LABEL: @fabs_ord(
; CHECK-NEXT: [[CALL:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[A:%.*]])
; CHECK-NEXT: [[CMP:%.*]] = fcmp arcp ord <2 x float> [[CALL]], zeroinitializer
; CHECK-NEXT: [[CMP:%.*]] = fcmp ord <2 x float> [[A:%.*]], zeroinitializer
; CHECK-NEXT: ret <2 x i1> [[CMP]]
;
%call = call <2 x float> @llvm.fabs.v2f32(<2 x float> %a)
@ -309,8 +308,7 @@ define <2 x i1> @fabs_ord(<2 x float> %a) {
define <2 x i1> @fabs_uno(<2 x float> %a) {
; CHECK-LABEL: @fabs_uno(
; CHECK-NEXT: [[CALL:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[A:%.*]])
; CHECK-NEXT: [[CMP:%.*]] = fcmp arcp uno <2 x float> [[CALL]], zeroinitializer
; CHECK-NEXT: [[CMP:%.*]] = fcmp uno <2 x float> [[A:%.*]], zeroinitializer
; CHECK-NEXT: ret <2 x i1> [[CMP]]
;
%call = call <2 x float> @llvm.fabs.v2f32(<2 x float> %a)