[PATCH] D36498: [InstCombine] Teach foldSelectICmpAnd to recognize a (icmp slt trunc X, 0) and (icmp sgt trunc X, -1) as equivalent to an and with the sign bit of the truncated type
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 14 10:26:19 PDT 2017
craig.topper added a comment.
This patch is really just making InstCombine self consistent. We currently optimize this case differently depending on whether i8 is legal in datalayout.
define i32 @test71(i32 %x) {
; CHECK-LABEL: @test71(
; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X:%.*]], 6
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 2
; CHECK-NEXT: [[TMP3:%.*]] = or i32 [[TMP2]], 40
; CHECK-NEXT: ret i32 [[TMP3]]
;
%1 = and i32 %x, 128
%2 = icmp eq i32 %1, 0
%3 = select i1 %2, i32 40, i32 42
ret i32 %3
}
If we want to remove foldSelectICmpAnd that's a different question.
https://reviews.llvm.org/D36498
More information about the llvm-commits
mailing list