-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ValueTracking] Don't use CondContext in dataflow analysis of phi nod…
…es (#100316) See the following case: ``` define i16 @pr100298() { entry: br label %for.inc for.inc: %indvar = phi i32 [ -15, %entry ], [ %mask, %for.inc ] %add = add nsw i32 %indvar, 9 %mask = and i32 %add, 65535 %cmp1 = icmp ugt i32 %mask, 5 br i1 %cmp1, label %for.inc, label %for.end for.end: %conv = trunc i32 %add to i16 %cmp2 = icmp ugt i32 %mask, 3 %shl = shl nuw i16 %conv, 14 %res = select i1 %cmp2, i16 %conv, i16 %shl ret i16 %res } ``` When computing knownbits of `%shl` with `%cmp2=false`, we cannot use this condition in the analysis of `%mask (%for.inc -> %for.inc)`. Fixes #100298.
- Loading branch information
Showing
3 changed files
with
56 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -S -passes=instcombine < %s | FileCheck %s | ||
|
||
; Make sure that the result of computeKnownBits for %indvar is correct. | ||
|
||
define i16 @pr100298() { | ||
; CHECK-LABEL: define i16 @pr100298() { | ||
; CHECK-NEXT: [[ENTRY:.*]]: | ||
; CHECK-NEXT: br label %[[FOR_INC:.*]] | ||
; CHECK: [[FOR_INC]]: | ||
; CHECK-NEXT: [[INDVAR:%.*]] = phi i32 [ -15, %[[ENTRY]] ], [ [[MASK:%.*]], %[[FOR_INC]] ] | ||
; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[INDVAR]], 9 | ||
; CHECK-NEXT: [[MASK]] = and i32 [[ADD]], 65535 | ||
; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[MASK]], 5 | ||
; CHECK-NEXT: br i1 [[CMP1]], label %[[FOR_INC]], label %[[FOR_END:.*]] | ||
; CHECK: [[FOR_END]]: | ||
; CHECK-NEXT: [[CONV:%.*]] = trunc i32 [[ADD]] to i16 | ||
; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i32 [[MASK]], 3 | ||
; CHECK-NEXT: [[SHL:%.*]] = shl nuw i16 [[CONV]], 14 | ||
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP2]], i16 [[CONV]], i16 [[SHL]] | ||
; CHECK-NEXT: ret i16 [[RES]] | ||
; | ||
entry: | ||
br label %for.inc | ||
|
||
for.inc: | ||
%indvar = phi i32 [ -15, %entry ], [ %mask, %for.inc ] | ||
%add = add nsw i32 %indvar, 9 | ||
%mask = and i32 %add, 65535 | ||
%cmp1 = icmp ugt i32 %mask, 5 | ||
br i1 %cmp1, label %for.inc, label %for.end | ||
|
||
for.end: | ||
%conv = trunc i32 %add to i16 | ||
%cmp2 = icmp ugt i32 %mask, 3 | ||
%shl = shl nuw i16 %conv, 14 | ||
%res = select i1 %cmp2, i16 %conv, i16 %shl | ||
ret i16 %res | ||
} |