[PATCH] D57044: [AArch64] Optimize Inf materialization
Adhemerval Zanella via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 22 03:12:44 PST 2019
zatrazz created this revision.
zatrazz added reviewers: fhahn, javed.absar, huntergr, SjoerdMeijer, t.p.northover, echristo, evandro, rengolin.
Herald added a subscriber: kristof.beyls.
We can materialize Inf on isFPImmLegal for both float and double. It optimizes isinf slight as well.
Repository:
rL LLVM
https://reviews.llvm.org/D57044
Files:
lib/Target/AArch64/AArch64ISelLowering.cpp
test/CodeGen/AArch64/known-never-nan.ll
Index: test/CodeGen/AArch64/known-never-nan.ll
===================================================================
--- test/CodeGen/AArch64/known-never-nan.ll
+++ test/CodeGen/AArch64/known-never-nan.ll
@@ -28,13 +28,13 @@
define float @not_fmaxnm_maybe_nan(i32 %i1, i32 %i2) #0 {
; CHECK-LABEL: not_fmaxnm_maybe_nan:
; CHECK: // %bb.0:
-; CHECK-NEXT: adrp x8, .LCPI1_0
-; CHECK-NEXT: ldr s0, [x8, :lo12:.LCPI1_0]
-; CHECK-NEXT: ucvtf s1, w0
-; CHECK-NEXT: ucvtf s2, w1
-; CHECK-NEXT: fmov s3, #17.00000000
-; CHECK-NEXT: fmul s0, s1, s0
-; CHECK-NEXT: fadd s1, s2, s3
+; CHECK-NEXT: orr w8, wzr, #0xff800000
+; CHECK-NEXT: ucvtf s0, w0
+; CHECK-NEXT: ucvtf s1, w1
+; CHECK-NEXT: fmov s2, #17.00000000
+; CHECK-NEXT: fmov s3, w8
+; CHECK-NEXT: fmul s0, s0, s3
+; CHECK-NEXT: fadd s1, s1, s2
; CHECK-NEXT: fcmp s0, s1
; CHECK-NEXT: fcsel s0, s0, s1, pl
; CHECK-NEXT: ret
Index: lib/Target/AArch64/AArch64ISelLowering.cpp
===================================================================
--- lib/Target/AArch64/AArch64ISelLowering.cpp
+++ lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -5426,11 +5426,14 @@
}
bool AArch64TargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT) const {
- // We can materialize #0.0 as fmov $Rd, XZR for 64-bit and 32-bit cases.
+ // We can materialize #0.0 and #INF as fmov $Rd, XZR for 64-bit and 32-bit
+ // cases.
// FIXME: We should be able to handle f128 as well with a clever lowering.
- if (Imm.isPosZero() && (VT == MVT::f64 || VT == MVT::f32 ||
- (VT == MVT::f16 && Subtarget->hasFullFP16()))) {
- LLVM_DEBUG(dbgs() << "Legal " << VT.getEVTString() << " imm value: 0\n");
+ if ((Imm.isPosZero() || Imm.isInfinity()) &&
+ (VT == MVT::f64 || VT == MVT::f32 ||
+ (VT == MVT::f16 && Subtarget->hasFullFP16()))) {
+ LLVM_DEBUG(dbgs() << "Legal " << VT.getEVTString() << " imm value: "
+ << (Imm.isPosZero() ? "0" : "Inf") << "\n");
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57044.182878.patch
Type: text/x-patch
Size: 2031 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190122/203c3f56/attachment.bin>
More information about the llvm-commits
mailing list