[PATCH] D84597: [ConstantFolding] Fold freeze if it is never undef or poison
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 26 05:55:32 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG32088f4f7fc7: [ConstantFolding] Fold freeze if it is never undef or poison (authored by aqjune).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84597/new/
https://reviews.llvm.org/D84597
Files:
llvm/lib/Analysis/ConstantFolding.cpp
llvm/test/Analysis/ConstantFolding/freeze.ll
Index: llvm/test/Analysis/ConstantFolding/freeze.ll
===================================================================
--- llvm/test/Analysis/ConstantFolding/freeze.ll
+++ llvm/test/Analysis/ConstantFolding/freeze.ll
@@ -6,8 +6,7 @@
define i64 @ptrdiff1() {
; CHECK-LABEL: @ptrdiff1(
-; CHECK-NEXT: [[R:%.*]] = freeze i64 sub (i64 ptrtoint (i16* @g to i64), i64 ptrtoint (i16* @g2 to i64))
-; CHECK-NEXT: ret i64 [[R]]
+; CHECK-NEXT: ret i64 sub (i64 ptrtoint (i16* @g to i64), i64 ptrtoint (i16* @g2 to i64))
;
%i = ptrtoint i16* @g to i64
%i2 = ptrtoint i16* @g2 to i64
@@ -18,8 +17,7 @@
define i64 @ptrdiff2() {
; CHECK-LABEL: @ptrdiff2(
-; CHECK-NEXT: [[R:%.*]] = freeze i64 -2
-; CHECK-NEXT: ret i64 [[R]]
+; CHECK-NEXT: ret i64 -2
;
%i = ptrtoint i16* @g to i64
%gep = getelementptr i16, i16* @g, i64 1
Index: llvm/lib/Analysis/ConstantFolding.cpp
===================================================================
--- llvm/lib/Analysis/ConstantFolding.cpp
+++ llvm/lib/Analysis/ConstantFolding.cpp
@@ -1071,6 +1071,8 @@
default: return nullptr;
case Instruction::ICmp:
case Instruction::FCmp: llvm_unreachable("Invalid for compares");
+ case Instruction::Freeze:
+ return isGuaranteedNotToBeUndefOrPoison(Ops[0]) ? Ops[0] : nullptr;
case Instruction::Call:
if (auto *F = dyn_cast<Function>(Ops.back())) {
const auto *Call = cast<CallBase>(InstOrCE);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84597.280722.patch
Type: text/x-patch
Size: 1427 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200726/1a565184/attachment.bin>
More information about the llvm-commits
mailing list