forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GVN][NewGVN][Local] Handle attributes for function calls after CSE (l…
…lvm#114011) This patch intersects attributes of two calls to avoid introducing UB. It also skips incompatible call pairs in GVN/NewGVN. However, I cannot provide negative tests for these changes. Fixes llvm#113997.
- Loading branch information
Showing
5 changed files
with
114 additions
and
7 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
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,33 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -S -passes=gvn < %s | FileCheck %s | ||
|
||
; Make sure attributes in function calls are intersected correctly. | ||
|
||
define i1 @bucket(i32 noundef %x) { | ||
; CHECK-LABEL: define i1 @bucket( | ||
; CHECK-SAME: i32 noundef [[X:%.*]]) { | ||
; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[X]], 0 | ||
; CHECK-NEXT: [[CTPOP1:%.*]] = tail call range(i32 0, 33) i32 @llvm.ctpop.i32(i32 [[X]]) | ||
; CHECK-NEXT: [[CMP2:%.*]] = icmp samesign ult i32 [[CTPOP1]], 2 | ||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP1]], i1 [[CMP2]], i1 false | ||
; CHECK-NEXT: br i1 [[COND]], label %[[IF_THEN:.*]], label %[[IF_ELSE:.*]] | ||
; CHECK: [[IF_ELSE]]: | ||
; CHECK-NEXT: [[RES:%.*]] = icmp eq i32 [[CTPOP1]], 1 | ||
; CHECK-NEXT: ret i1 [[RES]] | ||
; CHECK: [[IF_THEN]]: | ||
; CHECK-NEXT: ret i1 false | ||
; | ||
%cmp1 = icmp sgt i32 %x, 0 | ||
%ctpop1 = tail call range(i32 1, 32) i32 @llvm.ctpop.i32(i32 %x) | ||
%cmp2 = icmp samesign ult i32 %ctpop1, 2 | ||
%cond = select i1 %cmp1, i1 %cmp2, i1 false | ||
br i1 %cond, label %if.then, label %if.else | ||
|
||
if.else: | ||
%ctpop2 = tail call range(i32 0, 33) i32 @llvm.ctpop.i32(i32 %x) | ||
%res = icmp eq i32 %ctpop2, 1 | ||
ret i1 %res | ||
|
||
if.then: | ||
ret i1 false | ||
} |
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,33 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -S -passes=newgvn < %s | FileCheck %s | ||
|
||
; Make sure attributes in function calls are intersected correctly. | ||
|
||
define i1 @bucket(i32 noundef %x) { | ||
; CHECK-LABEL: define i1 @bucket( | ||
; CHECK-SAME: i32 noundef [[X:%.*]]) { | ||
; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[X]], 0 | ||
; CHECK-NEXT: [[CTPOP1:%.*]] = tail call range(i32 0, 33) i32 @llvm.ctpop.i32(i32 [[X]]) | ||
; CHECK-NEXT: [[CMP2:%.*]] = icmp samesign ult i32 [[CTPOP1]], 2 | ||
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP1]], i1 [[CMP2]], i1 false | ||
; CHECK-NEXT: br i1 [[COND]], label %[[IF_THEN:.*]], label %[[IF_ELSE:.*]] | ||
; CHECK: [[IF_ELSE]]: | ||
; CHECK-NEXT: [[RES:%.*]] = icmp eq i32 [[CTPOP1]], 1 | ||
; CHECK-NEXT: ret i1 [[RES]] | ||
; CHECK: [[IF_THEN]]: | ||
; CHECK-NEXT: ret i1 false | ||
; | ||
%cmp1 = icmp sgt i32 %x, 0 | ||
%ctpop1 = tail call range(i32 1, 32) i32 @llvm.ctpop.i32(i32 %x) | ||
%cmp2 = icmp samesign ult i32 %ctpop1, 2 | ||
%cond = select i1 %cmp1, i1 %cmp2, i1 false | ||
br i1 %cond, label %if.then, label %if.else | ||
|
||
if.else: | ||
%ctpop2 = tail call range(i32 0, 33) i32 @llvm.ctpop.i32(i32 %x) | ||
%res = icmp eq i32 %ctpop2, 1 | ||
ret i1 %res | ||
|
||
if.then: | ||
ret i1 false | ||
} |