[llvm] r346327 - [InstCombine] peek through fabs() when checking isnan()
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 7 07:44:26 PST 2018
Author: spatel
Date: Wed Nov 7 07:44:26 2018
New Revision: 346327
URL: http://llvm.org/viewvc/llvm-project?rev=346327&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/trunk/test/Transforms/InstCombine/fcmp.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=346327&r1=346326&r2=346327&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Wed Nov 7 07:44:26 2018
@@ -5328,8 +5328,13 @@ static Instruction *foldFabsWithFcmpZero
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:
Modified: llvm/trunk/test/Transforms/InstCombine/fcmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fcmp.ll?rev=346327&r1=346326&r2=346327&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fcmp.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fcmp.ll Wed Nov 7 07:44:26 2018
@@ -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)
More information about the llvm-commits
mailing list