[PATCH] D94861: [InstCombine,InstSimplify] Optimize select followed by and/or/xor
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 16 03:43:09 PST 2021
aqjune added a comment.
After applying D94859 <https://reviews.llvm.org/D94859> + D94860 <https://reviews.llvm.org/D94860> + this patch, the diff looks like this:
https://gist.github.com/aqjune/39bcc99bf7339bef74652597c9e57122 (@nikic thanks for creating the _logical functions!)
I think the majority of sound transformations are now supported.
A few missing cases:
define i1 @test7_logical(i32 %i, i1 %b) {
; CHECK-LABEL: @test7_logical(
-; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[I:%.*]], 0
-; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[B:%.*]]
-; CHECK-NEXT: ret i1 [[TMP2]]
+; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[I:%.*]], 1
+; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i32 [[I]], -1
+; CHECK-NEXT: [[AND1:%.*]] = select i1 [[CMP1]], i1 [[B:%.*]], i1 false
+; CHECK-NEXT: [[AND2:%.*]] = and i1 [[AND1]], [[CMP2]]
+; CHECK-NEXT: ret i1 [[AND2]]
;
%cmp1 = icmp slt i32 %i, 1
%cmp2 = icmp sgt i32 %i, -1
as well as llvm.umul.with.overflow.i64 , llvm.ctpop.i32 .
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94861/new/
https://reviews.llvm.org/D94861
More information about the llvm-commits
mailing list