Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/include/llvm/Target/GlobalISel/Combine.td
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ def constant_fold_fabs : constant_fold_unary_fp_op_rule<G_FABS>;
def constant_fold_fsqrt : constant_fold_unary_fp_op_rule<G_FSQRT>;
def constant_fold_flog2 : constant_fold_unary_fp_op_rule<G_FLOG2>;
def constant_fold_fptrunc : constant_fold_unary_fp_op_rule<G_FPTRUNC>;
def constant_fold_fpext : constant_fold_unary_fp_op_rule<G_FPEXT>;

// Fold constant zero int to fp conversions.
class itof_const_zero_fold_rule<Instruction opcode> : GICombineRule <
Expand All @@ -713,6 +714,7 @@ def constant_fold_fp_ops : GICombineGroup<[
constant_fold_fsqrt,
constant_fold_flog2,
constant_fold_fptrunc,
constant_fold_fpext,
itof_const_zero_fold_si,
itof_const_zero_fold_ui
]>;
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,7 @@ static APFloat constantFoldFpUnary(const MachineInstr &MI,
Result.clearSign();
return Result;
}
case TargetOpcode::G_FPEXT:
case TargetOpcode::G_FPTRUNC: {
bool Unused;
LLT DstTy = MRI.getType(MI.getOperand(0).getReg());
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/AArch64Combine.td
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def AArch64PostLegalizerLowering
// Post-legalization combines which are primarily optimizations.
def AArch64PostLegalizerCombiner
: GICombiner<"AArch64PostLegalizerCombinerImpl",
[copy_prop, cast_of_cast_combines,
[copy_prop, cast_of_cast_combines, constant_fold_fp_ops,
buildvector_of_truncate, integer_of_truncate,
mutate_anyext_to_zext, combines_for_extload,
combine_indexed_load_store, sext_trunc_sextload,
Expand Down
10 changes: 4 additions & 6 deletions llvm/test/CodeGen/AArch64/arm64-indexed-memory.ll
Original file line number Diff line number Diff line change
Expand Up @@ -739,14 +739,12 @@ define ptr @postidx32_shalf(ptr %src, ptr %out, half %a) {
;
; GISEL-LABEL: postidx32_shalf:
; GISEL: ; %bb.0:
; GISEL-NEXT: movi d1, #0000000000000000
; GISEL-NEXT: ldr h2, [x0], #4
; GISEL-NEXT: ldr h1, [x0], #4
; GISEL-NEXT: ; kill: def $h0 killed $h0 def $s0
; GISEL-NEXT: fmov w9, s0
; GISEL-NEXT: fcvt s3, h2
; GISEL-NEXT: fmov w8, s2
; GISEL-NEXT: fcvt s1, h1
; GISEL-NEXT: fcmp s3, s1
; GISEL-NEXT: fcvt s2, h1
; GISEL-NEXT: fmov w8, s1
; GISEL-NEXT: fcmp s2, #0.0
; GISEL-NEXT: csel w8, w8, w9, mi
; GISEL-NEXT: strh w8, [x1]
; GISEL-NEXT: ret
Expand Down
18 changes: 8 additions & 10 deletions llvm/test/CodeGen/AArch64/f16-instructions.ll
Original file line number Diff line number Diff line change
Expand Up @@ -782,18 +782,16 @@ define void @test_fccmp(half %in, ptr %out) {
;
; CHECK-CVT-GI-LABEL: test_fccmp:
; CHECK-CVT-GI: // %bb.0:
; CHECK-CVT-GI-NEXT: adrp x8, .LCPI29_0
; CHECK-CVT-GI-NEXT: // kill: def $h0 killed $h0 def $s0
; CHECK-CVT-GI-NEXT: fcvt s2, h0
; CHECK-CVT-GI-NEXT: ldr h1, [x8, :lo12:.LCPI29_0]
; CHECK-CVT-GI-NEXT: adrp x8, .LCPI29_1
; CHECK-CVT-GI-NEXT: ldr h4, [x8, :lo12:.LCPI29_1]
; CHECK-CVT-GI-NEXT: fcvt s1, h0
; CHECK-CVT-GI-NEXT: fmov s2, #5.00000000
; CHECK-CVT-GI-NEXT: adrp x8, .LCPI29_0
; CHECK-CVT-GI-NEXT: fmov s3, #8.00000000
; CHECK-CVT-GI-NEXT: fcmp s1, s2
; CHECK-CVT-GI-NEXT: ldr h2, [x8, :lo12:.LCPI29_0]
; CHECK-CVT-GI-NEXT: fmov w8, s0
; CHECK-CVT-GI-NEXT: fcvt s3, h1
; CHECK-CVT-GI-NEXT: fmov w9, s1
; CHECK-CVT-GI-NEXT: fcvt s4, h4
; CHECK-CVT-GI-NEXT: fcmp s2, s3
; CHECK-CVT-GI-NEXT: fccmp s2, s4, #4, mi
; CHECK-CVT-GI-NEXT: fmov w9, s2
; CHECK-CVT-GI-NEXT: fccmp s1, s3, #4, mi
; CHECK-CVT-GI-NEXT: csel w8, w8, w9, gt
; CHECK-CVT-GI-NEXT: strh w8, [x0]
; CHECK-CVT-GI-NEXT: ret
Expand Down
Loading