Skip to content

Commit d6cfed4

Browse files
author
git apple-llvm automerger
committed
Merge commit '2526d8c43499' from llvm.org/release/11.x into apple/stable/20200714
2 parents 533a62a + 2526d8c commit d6cfed4

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3837,10 +3837,7 @@ static const Value *SimplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
38373837
// TODO: This is an unusual limitation because better analysis results in
38383838
// worse simplification. InstCombine can do this fold more generally
38393839
// by dropping the flags. Remove this fold to save compile-time?
3840-
if (isa<OverflowingBinaryOperator>(B))
3841-
if (Q.IIQ.hasNoSignedWrap(B) || Q.IIQ.hasNoUnsignedWrap(B))
3842-
return nullptr;
3843-
if (isa<PossiblyExactOperator>(B) && Q.IIQ.isExact(B))
3840+
if (canCreatePoison(I))
38443841
return nullptr;
38453842

38463843
if (MaxRecurse) {

llvm/test/Transforms/InstSimplify/select.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,3 +919,19 @@ define <2 x i32> @all_constant_true_undef_false_constexpr_vec() {
919919
%s = select i1 ptrtoint (<2 x i32> ()* @all_constant_true_undef_false_constexpr_vec to i1), <2 x i32> undef, <2 x i32><i32 -1, i32 ptrtoint (<2 x i32> ()* @all_constant_true_undef_false_constexpr_vec to i32)>
920920
ret <2 x i32> %s
921921
}
922+
923+
define i32 @pr47322_more_poisonous_replacement(i32 %arg) {
924+
; CHECK-LABEL: @pr47322_more_poisonous_replacement(
925+
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[ARG:%.*]], 0
926+
; CHECK-NEXT: [[TRAILING:%.*]] = call i32 @llvm.cttz.i32(i32 [[ARG]], i1 immarg true)
927+
; CHECK-NEXT: [[SHIFTED:%.*]] = lshr i32 [[ARG]], [[TRAILING]]
928+
; CHECK-NEXT: [[R1_SROA_0_1:%.*]] = select i1 [[CMP]], i32 0, i32 [[SHIFTED]]
929+
; CHECK-NEXT: ret i32 [[R1_SROA_0_1]]
930+
;
931+
%cmp = icmp eq i32 %arg, 0
932+
%trailing = call i32 @llvm.cttz.i32(i32 %arg, i1 immarg true)
933+
%shifted = lshr i32 %arg, %trailing
934+
%r1.sroa.0.1 = select i1 %cmp, i32 0, i32 %shifted
935+
ret i32 %r1.sroa.0.1
936+
}
937+
declare i32 @llvm.cttz.i32(i32, i1 immarg)

0 commit comments

Comments
 (0)