Skip to content

Commit

Permalink
[NewGVN] Fold equivalent freeze instructions
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D152529
  • Loading branch information
jayfoad committed Jun 9, 2023
1 parent b27b5dc commit c0ad1b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions llvm/lib/Transforms/Scalar/NewGVN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,7 @@ NewGVN::performSymbolicEvaluation(Value *V,
break;
case Instruction::BitCast:
case Instruction::AddrSpaceCast:
case Instruction::Freeze:
return createExpression(I);
break;
case Instruction::ICmp:
Expand Down
9 changes: 3 additions & 6 deletions llvm/test/Transforms/NewGVN/freeze.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
define i1 @f(i1 %a) {
; CHECK-LABEL: @f(
; CHECK-NEXT: [[B:%.*]] = freeze i1 [[A:%.*]]
; CHECK-NEXT: [[C:%.*]] = freeze i1 [[A]]
; CHECK-NEXT: [[D:%.*]] = and i1 [[B]], [[C]]
; CHECK-NEXT: ret i1 [[D]]
; CHECK-NEXT: ret i1 [[B]]
;
%b = freeze i1 %a
%c = freeze i1 %a
Expand All @@ -17,10 +15,9 @@ define i1 @f(i1 %a) {
define void @f_multipleuses(i1 %a) {
; CHECK-LABEL: @f_multipleuses(
; CHECK-NEXT: [[B:%.*]] = freeze i1 [[A:%.*]]
; CHECK-NEXT: [[C:%.*]] = freeze i1 [[A]]
; CHECK-NEXT: call void @use1(i1 [[B]])
; CHECK-NEXT: call void @use1(i1 [[C]])
; CHECK-NEXT: call void @use1(i1 [[C]])
; CHECK-NEXT: call void @use1(i1 [[B]])
; CHECK-NEXT: call void @use1(i1 [[B]])
; CHECK-NEXT: ret void
;
%b = freeze i1 %a
Expand Down

0 comments on commit c0ad1b4

Please sign in to comment.