[PATCH] D103057: [SystemZ] Return true from preferZeroCompareBranch()
Jonas Paulsson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 24 17:08:39 PDT 2021
jonpa created this revision.
jonpa added a reviewer: uweigand.
Herald added a subscriber: hiraditya.
jonpa requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Doing this seems to eliminate compares overall on benchmarks:
cijlh : 78588 77953 -635
ahik : 72595 71970 -625
jlh : 165486 166049 +563
ahi : 89115 89660 +545
je : 337157 337319 +162
...
https://reviews.llvm.org/D103057
Files:
llvm/lib/Target/SystemZ/SystemZISelLowering.h
llvm/test/CodeGen/SystemZ/codegenprepare-form-OF-ops.ll
Index: llvm/test/CodeGen/SystemZ/codegenprepare-form-OF-ops.ll
===================================================================
--- llvm/test/CodeGen/SystemZ/codegenprepare-form-OF-ops.ll
+++ llvm/test/CodeGen/SystemZ/codegenprepare-form-OF-ops.ll
@@ -52,3 +52,41 @@
%tmp12 = select i1 %tmp10, i64 %tmp11, i64 %arg
ret i64 %tmp12
}
+
+define i32 @optbranch_32(i32 %Arg) {
+; CHECK-LABEL: optbranch_32:
+; CHECK: alhsik %r2, %r2, 1
+; CHECK-NEXT: bler %r14
+; CHECK-NEXT: .LBB4_1:
+; CHECK-NEXT: lhi %r2, -1
+; CHECK-NEXT: br %r14
+bb:
+ %i1 = icmp eq i32 %Arg, -1
+ br i1 %i1, label %bb2, label %bb3
+
+bb2:
+ ret i32 -1
+
+bb3:
+ %i4 = add nuw i32 %Arg, 1
+ ret i32 %i4
+}
+
+define i64 @optbranch_64(i64 %Arg) {
+; CHECK-LABEL: optbranch_64:
+; CHECK: alghsik %r2, %r2, 1
+; CHECK-NEXT: bler %r14
+; CHECK-NEXT: .LBB5_1:
+; CHECK-NEXT: lghi %r2, -1
+; CHECK-NEXT: br %r14
+bb:
+ %i1 = icmp eq i64 %Arg, -1
+ br i1 %i1, label %bb2, label %bb3
+
+bb2:
+ ret i64 -1
+
+bb3:
+ %i4 = add nuw i64 %Arg, 1
+ ret i64 %i4
+}
Index: llvm/lib/Target/SystemZ/SystemZISelLowering.h
===================================================================
--- llvm/lib/Target/SystemZ/SystemZISelLowering.h
+++ llvm/lib/Target/SystemZ/SystemZISelLowering.h
@@ -423,6 +423,7 @@
return TargetLoweringBase::getPreferredVectorAction(VT);
}
bool isCheapToSpeculateCtlz() const override { return true; }
+ bool preferZeroCompareBranch() const override { return true; }
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &,
EVT) const override;
bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103057.347532.patch
Type: text/x-patch
Size: 1675 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210525/707abe57/attachment.bin>
More information about the llvm-commits
mailing list