Skip to content

Commit 37f1d40

Browse files
committed
wip
1 parent 2cb5241 commit 37f1d40

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ static bool isEphemeralValueOf(const Instruction *I, const Value *E) {
457457
continue;
458458

459459
// If all uses of this value are ephemeral, then so is this value.
460-
if (llvm::all_of(V->users(), [&](const User *U) {
460+
if (V == I || llvm::any_of(V->users(), [&](const User *U) {
461461
return EphValues.count(U);
462462
})) {
463463
if (V == E)

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3217,7 +3217,7 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
32173217
m_Zero())) &&
32183218
LHS->getOpcode() == Instruction::Load &&
32193219
LHS->getType()->isPointerTy() &&
3220-
isValidAssumeForContext(II, LHS, &DT)) {
3220+
isValidAssumeForContext(II, LHS, &DT, /*AllowEphemeral=*/true)) {
32213221
MDNode *MD = MDNode::get(II->getContext(), {});
32223222
LHS->setMetadata(LLVMContext::MD_nonnull, MD);
32233223
LHS->setMetadata(LLVMContext::MD_noundef, MD);

llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ struct AssumeSimplify {
432432
continue;
433433
}
434434
if (isValidAssumeForContext(
435-
Assume, &*F.getEntryBlock().getFirstInsertionPt()) ||
435+
Assume, &*F.getEntryBlock().getFirstInsertionPt(),
436+
/*DT=*/nullptr, /*AllowEphemeral=*/true) ||
436437
Assume == &*F.getEntryBlock().getFirstInsertionPt()) {
437438
if (HasSameKindAttr)
438439
Arg->removeAttr(RK.AttrKind);

llvm/test/Analysis/ScalarEvolution/trunc-simplify.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ define i8 @trunc_to_assumed_zeros(ptr %p) {
4141
; CHECK-LABEL: 'trunc_to_assumed_zeros'
4242
; CHECK-NEXT: Classifying expressions for: @trunc_to_assumed_zeros
4343
; CHECK-NEXT: %a = load i32, ptr %p, align 4
44-
; CHECK-NEXT: --> %a U: [0,-255) S: [-2147483648,2147483393)
44+
; CHECK-NEXT: --> %a U: full-set S: full-set
4545
; CHECK-NEXT: %and = and i32 %a, 255
46-
; CHECK-NEXT: --> 0 U: [0,1) S: [0,1)
46+
; CHECK-NEXT: --> (zext i8 (trunc i32 %a to i8) to i32) U: [0,256) S: [0,256)
4747
; CHECK-NEXT: %c = trunc i32 %a to i8
48-
; CHECK-NEXT: --> 0 U: [0,1) S: [0,1)
48+
; CHECK-NEXT: --> (trunc i32 %a to i8) U: full-set S: full-set
4949
; CHECK-NEXT: %d = trunc i32 %a to i1
50-
; CHECK-NEXT: --> false U: [0,-1) S: [0,-1)
50+
; CHECK-NEXT: --> (trunc i32 %a to i1) U: full-set S: full-set
5151
; CHECK-NEXT: %e = trunc i32 %a to i16
52-
; CHECK-NEXT: --> (trunc i32 %a to i16) U: [0,-255) S: [-32768,32513)
52+
; CHECK-NEXT: --> (trunc i32 %a to i16) U: full-set S: full-set
5353
; CHECK-NEXT: Determining loop execution counts for: @trunc_to_assumed_zeros
5454
;
5555
%a = load i32, ptr %p

llvm/test/Analysis/ValueTracking/numsignbits-from-assume.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ define i32 @computeNumSignBits_sub1(i32 %in) {
4848

4949
define i32 @computeNumSignBits_sub2(i32 %in) {
5050
; CHECK-LABEL: @computeNumSignBits_sub2(
51-
; CHECK-NEXT: [[SUB:%.*]] = add nsw i32 [[IN:%.*]], -1
51+
; CHECK-NEXT: [[SUB:%.*]] = add i32 [[IN:%.*]], -1
5252
; CHECK-NEXT: [[COND:%.*]] = icmp ult i32 [[SUB]], 43
5353
; CHECK-NEXT: call void @llvm.assume(i1 [[COND]])
5454
; CHECK-NEXT: [[SH:%.*]] = shl nuw nsw i32 [[SUB]], 3

llvm/test/Transforms/InstCombine/assume.ll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,9 @@ define i1 @nonnull3B(ptr %a, i1 %control) {
502502
; CHECK-NEXT: entry:
503503
; CHECK-NEXT: br i1 [[CONTROL:%.*]], label [[TAKEN:%.*]], label [[NOT_TAKEN:%.*]]
504504
; CHECK: taken:
505-
; CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr [[A:%.*]], align 8
506-
; CHECK-NEXT: [[CMP:%.*]] = icmp ne ptr [[LOAD]], null
507-
; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]]) [ "nonnull"(ptr [[LOAD]]) ]
508-
; CHECK-NEXT: ret i1 [[CMP]]
505+
; CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr [[A:%.*]], align 8, !nonnull [[META6]], !noundef [[META6]]
506+
; CHECK-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(ptr [[LOAD]]) ]
507+
; CHECK-NEXT: ret i1 true
509508
; CHECK: not_taken:
510509
; CHECK-NEXT: ret i1 false
511510
;

llvm/test/Transforms/InstCombine/zext-or-icmp.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ define i8 @PR49475_infloop(i32 %t0, i16 %insert, i64 %e, i8 %i162) "instcombine-
180180
; CHECK-NEXT: [[SEXT:%.*]] = shl i64 [[SUB17]], 32
181181
; CHECK-NEXT: [[CONV18:%.*]] = ashr exact i64 [[SEXT]], 32
182182
; CHECK-NEXT: [[CMP:%.*]] = icmp sge i64 [[XOR]], [[CONV18]]
183-
; CHECK-NEXT: [[TRUNC44:%.*]] = zext i1 [[CMP]] to i8
184-
; CHECK-NEXT: [[INC:%.*]] = add i8 [[I162]], [[TRUNC44]]
185-
; CHECK-NEXT: [[TOBOOL23_NOT:%.*]] = xor i1 [[CMP]], true
183+
; CHECK-NEXT: [[CONV19:%.*]] = zext i1 [[CMP]] to i16
184+
; CHECK-NEXT: [[OR21:%.*]] = or i16 [[INSERT]], [[CONV19]]
185+
; CHECK-NEXT: [[TOBOOL23_NOT:%.*]] = icmp eq i16 [[OR21]], 0
186186
; CHECK-NEXT: call void @llvm.assume(i1 [[TOBOOL23_NOT]])
187-
; CHECK-NEXT: ret i8 [[INC]]
187+
; CHECK-NEXT: ret i8 [[I162]]
188188
;
189189
%b = icmp eq i32 %t0, 0
190190
%b2 = icmp eq i16 %insert, 0

0 commit comments

Comments
 (0)