-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[LV] Fix for miscompile with disjoint or #81922
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,102 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 | ||
; RUN: opt -S -passes=loop-vectorize < %s | FileCheck %s | ||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
@global = external global ptr addrspace(1), align 8 | ||
|
||
; PR 81872 explains the issue. | ||
|
||
; If we vectorize, we have a miscompile where array IV and thereby value stored in (arr[99], | ||
; arr[98]) is calculated incorrectly since disjoint or was only disjoint because | ||
; of dominating conditions. Dropping the disjoint to avoid poison still changes | ||
; the behaviour since now the or is not longer equivalent to the add. | ||
; Function Attrs: uwtable | ||
define void @test(ptr addrspace(1) noundef align 8 dereferenceable_or_null(16) %arg1) #0 { | ||
; CHECK-LABEL: define void @test( | ||
; CHECK-SAME: ptr addrspace(1) noundef align 8 dereferenceable_or_null(16) [[ARG1:%.*]]) #[[ATTR0:[0-9]+]] { | ||
; CHECK-NEXT: bb5: | ||
; CHECK-NEXT: [[GETELEMENTPTR:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[ARG1]], i64 16 | ||
; CHECK-NEXT: br label [[BB8:%.*]] | ||
; CHECK: bb6: | ||
; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[PHI9:%.*]], 1 | ||
; CHECK-NEXT: [[ICMP7:%.*]] = icmp sgt i32 [[PHI9]], -2 | ||
; CHECK-NEXT: br i1 [[ICMP7]], label [[BB10:%.*]], label [[BB8]] | ||
; CHECK: bb8: | ||
; CHECK-NEXT: [[PHI9]] = phi i32 [ -60516, [[BB5:%.*]] ], [ [[ADD]], [[BB6:%.*]] ] | ||
; CHECK-NEXT: br label [[BB15:%.*]] | ||
; CHECK: bb10: | ||
; CHECK-NEXT: [[GETELEMENTPTR11:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[ARG1]], i64 96 | ||
; CHECK-NEXT: [[LOAD12:%.*]] = load i64, ptr addrspace(1) [[GETELEMENTPTR11]], align 8, !noundef [[META0:![0-9]+]] | ||
; CHECK-NEXT: [[LOAD13:%.*]] = load ptr addrspace(1), ptr @global, align 8, !invariant.load [[META0]], !nonnull [[META0]], !dereferenceable_or_null !1, !align [[META2:![0-9]+]] | ||
; CHECK-NEXT: [[GETELEMENTPTR14:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[LOAD13]], i64 848 | ||
; CHECK-NEXT: store i64 [[LOAD12]], ptr addrspace(1) [[GETELEMENTPTR14]], align 8 | ||
; CHECK-NEXT: ret void | ||
; CHECK: bb15: | ||
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 99, [[BB8]] ], [ [[IV_NEXT:%.*]], [[BB20:%.*]] ] | ||
; CHECK-NEXT: [[AND:%.*]] = and i64 [[IV]], 1 | ||
; CHECK-NEXT: [[ICMP17:%.*]] = icmp eq i64 [[AND]], 0 | ||
; CHECK-NEXT: br i1 [[ICMP17]], label [[BB18:%.*]], label [[BB20]], !prof [[PROF3:![0-9]+]] | ||
; CHECK: bb18: | ||
; CHECK-NEXT: [[OR:%.*]] = or disjoint i64 [[IV]], 1 | ||
; CHECK-NEXT: [[GETELEMENTPTR19:%.*]] = getelementptr inbounds i64, ptr addrspace(1) [[GETELEMENTPTR]], i64 [[OR]] | ||
; CHECK-NEXT: store i64 1, ptr addrspace(1) [[GETELEMENTPTR19]], align 8 | ||
; CHECK-NEXT: br label [[BB20]] | ||
; CHECK: bb20: | ||
; CHECK-NEXT: [[IV_NEXT]] = add nsw i64 [[IV]], -1 | ||
; CHECK-NEXT: [[ICMP22:%.*]] = icmp eq i64 [[IV_NEXT]], 90 | ||
; CHECK-NEXT: br i1 [[ICMP22]], label [[BB6]], label [[BB15]], !prof [[PROF4:![0-9]+]] | ||
; | ||
bb5: | ||
%getelementptr = getelementptr inbounds i8, ptr addrspace(1) %arg1, i64 16 | ||
br label %bb8 | ||
|
||
bb6: ; preds = %bb20 | ||
%add = add nsw i32 %phi9, 1 | ||
annamthomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
%icmp7 = icmp sgt i32 %phi9, -2 | ||
br i1 %icmp7, label %bb10, label %bb8 | ||
|
||
bb8: ; preds = %bb6, %bb5 | ||
%phi9 = phi i32 [ -60516, %bb5 ], [ %add, %bb6 ] | ||
br label %bb15 | ||
|
||
bb10: ; preds = %bb6 | ||
%getelementptr11 = getelementptr inbounds i8, ptr addrspace(1) %arg1, i64 96 | ||
%load12 = load i64, ptr addrspace(1) %getelementptr11, align 8, !noundef !4 | ||
%load13 = load ptr addrspace(1), ptr @global, align 8, !invariant.load !4, !nonnull !4, !dereferenceable_or_null !16, !align !17 | ||
%getelementptr14 = getelementptr inbounds i8, ptr addrspace(1) %load13, i64 848 | ||
store i64 %load12, ptr addrspace(1) %getelementptr14, align 8 | ||
ret void | ||
|
||
bb15: ; preds = %bb20, %bb8 | ||
%iv = phi i64 [ 99, %bb8 ], [ %iv.next, %bb20 ] | ||
%and = and i64 %iv, 1 | ||
%icmp17 = icmp eq i64 %and, 0 | ||
br i1 %icmp17, label %bb18, label %bb20, !prof !21 | ||
|
||
bb18: ; preds = %bb15 | ||
%or = or disjoint i64 %iv, 1 | ||
%getelementptr19 = getelementptr inbounds i64, ptr addrspace(1) %getelementptr, i64 %or | ||
annamthomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
store i64 1, ptr addrspace(1) %getelementptr19, align 8 | ||
br label %bb20 | ||
|
||
bb20: ; preds = %bb18, %bb15 | ||
%iv.next = add nsw i64 %iv, -1 | ||
%icmp22 = icmp eq i64 %iv.next, 90 | ||
br i1 %icmp22, label %bb6, label %bb15, !prof !22 | ||
} | ||
|
||
attributes #0 = {"target-cpu"="haswell" "target-features"="+avx2" } | ||
|
||
!4 = !{} | ||
!10 = !{i32 1} | ||
!16 = !{i64 864} | ||
!17 = !{i64 8} | ||
!21 = !{!"branch_weights", i32 1, i32 1} | ||
!22 = !{!"branch_weights", i32 1, i32 95} | ||
;. | ||
; CHECK: [[META0]] = !{} | ||
; CHECK: [[META2]] = !{i64 8} | ||
; CHECK: [[PROF3]] = !{!"branch_weights", i32 1, i32 1} | ||
; CHECK: [[PROF4]] = !{!"branch_weights", i32 1, i32 95} | ||
;. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.