Skip to content

[CVP] Infer nneg on zext when forming from non-negative sext. #70715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ static bool processSExt(SExtInst *SDI, LazyValueInfo *LVI) {
auto *ZExt = CastInst::CreateZExtOrBitCast(Base, SDI->getType(), "", SDI);
ZExt->takeName(SDI);
ZExt->setDebugLoc(SDI->getDebugLoc());
ZExt->setNonNeg();
SDI->replaceAllUsesWith(ZExt);
SDI->eraseFromParent();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ define i16 @ashr_convert(i16 noundef %x, i16 %y) {

define i32 @sext_convert(i16 noundef %x) {
; CHECK-LABEL: @sext_convert(
; CHECK-NEXT: [[EXT:%.*]] = zext i16 [[X:%.*]] to i32
; CHECK-NEXT: [[EXT:%.*]] = zext nneg i16 [[X:%.*]] to i32
; CHECK-NEXT: [[CMP:%.*]] = icmp sge i16 [[X]], 0
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 [[EXT]], i32 24
; CHECK-NEXT: ret i32 [[SEL]]
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/CorrelatedValuePropagation/sext.ll
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define void @test1(i32 %n) {
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[A]], -1
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[EXT_WIDE1:%.*]] = zext i32 [[A]] to i64
; CHECK-NEXT: [[EXT_WIDE1:%.*]] = zext nneg i32 [[A]] to i64
; CHECK-NEXT: call void @use64(i64 [[EXT_WIDE1]])
; CHECK-NEXT: [[EXT]] = trunc i64 [[EXT_WIDE1]] to i32
; CHECK-NEXT: br label [[FOR_COND]]
Expand Down Expand Up @@ -85,7 +85,7 @@ define void @test3(i32 %n) {
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N:%.*]], -1
; CHECK-NEXT: br i1 [[CMP]], label [[BB:%.*]], label [[EXIT:%.*]]
; CHECK: bb:
; CHECK-NEXT: [[EXT_WIDE1:%.*]] = zext i32 [[N]] to i64
; CHECK-NEXT: [[EXT_WIDE1:%.*]] = zext nneg i32 [[N]] to i64
; CHECK-NEXT: call void @use64(i64 [[EXT_WIDE1]])
; CHECK-NEXT: [[EXT:%.*]] = trunc i64 [[EXT_WIDE1]] to i32
; CHECK-NEXT: br label [[EXIT]]
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/PhaseOrdering/AArch64/loopflatten.ll
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ define dso_local void @_Z3fooPiii(ptr %A, i32 %N, i32 %M) #0 {
; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[CMP3]], i1 [[CMP21]], i1 false
; CHECK-NEXT: br i1 [[OR_COND]], label [[FOR_COND1_PREHEADER_LR_PH_SPLIT_US:%.*]], label [[FOR_COND_CLEANUP:%.*]]
; CHECK: for.cond1.preheader.lr.ph.split.us:
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[M]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[N]] to i64
; CHECK-NEXT: [[TMP0:%.*]] = zext nneg i32 [[M]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = zext nneg i32 [[N]] to i64
; CHECK-NEXT: [[FLATTEN_TRIPCOUNT:%.*]] = mul nuw nsw i64 [[TMP0]], [[TMP1]]
; CHECK-NEXT: br label [[FOR_COND1_PREHEADER_US:%.*]]
; CHECK: for.cond1.preheader.us:
Expand Down