[llvm] 1bf261c - InstCombine: Fix metadata arguments blocking freeze combining
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 12 20:22:41 PST 2022
Author: Matt Arsenault
Date: 2022-12-12T22:57:49-05:00
New Revision: 1bf261c89b96df33ed14c6695f5f8590578e825d
URL: https://github.com/llvm/llvm-project/commit/1bf261c89b96df33ed14c6695f5f8590578e825d
DIFF: https://github.com/llvm/llvm-project/commit/1bf261c89b96df33ed14c6695f5f8590578e825d.diff
LOG: InstCombine: Fix metadata arguments blocking freeze combining
These are used for special arguments to intrinsics and don't make any
sense to consider for poisonness. Fixes not pushing freeze through
llvm.fptrunc.round.
92106641ae297c24877085e0357e8095aa7b43c9 made
isGuaranteedNotToBeUndefOrPoison return false for metadata arguments,
which doesn't entirely make sense. An alternate patch could switch
that to true, and try to filter out adding some pointless noundefs on
metadata arguments (I tried that, attributor breaks one case with a
llvm.dbg.value in it).
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/freeze-fp-ops.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 8a8e6e6996c3c..2e41886359dab 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -3801,7 +3801,8 @@ InstCombinerImpl::pushFreezeToPreventPoisonFromPropagating(FreezeInst &OrigFI) {
// poison.
Use *MaybePoisonOperand = nullptr;
for (Use &U : OrigOpInst->operands()) {
- if (isGuaranteedNotToBeUndefOrPoison(U.get()))
+ if (isa<MetadataAsValue>(U.get()) ||
+ isGuaranteedNotToBeUndefOrPoison(U.get()))
continue;
if (!MaybePoisonOperand)
MaybePoisonOperand = &U;
diff --git a/llvm/test/Transforms/InstCombine/freeze-fp-ops.ll b/llvm/test/Transforms/InstCombine/freeze-fp-ops.ll
index 4d4af0572ec48..3a45530fbc99e 100644
--- a/llvm/test/Transforms/InstCombine/freeze-fp-ops.ll
+++ b/llvm/test/Transforms/InstCombine/freeze-fp-ops.ll
@@ -508,9 +508,9 @@ define i1 @freeze_isfpclass(float %arg0) {
define float @freeze_fptrunc_round(double %arg0) {
; CHECK-LABEL: @freeze_fptrunc_round(
-; CHECK-NEXT: [[OP:%.*]] = call float @llvm.fptrunc.round.f32.f64(double [[ARG0:%.*]], metadata !"round.downward")
-; CHECK-NEXT: [[FREEZE:%.*]] = freeze float [[OP]]
-; CHECK-NEXT: ret float [[FREEZE]]
+; CHECK-NEXT: [[ARG0_FR:%.*]] = freeze double [[ARG0:%.*]]
+; CHECK-NEXT: [[OP:%.*]] = call float @llvm.fptrunc.round.f32.f64(double [[ARG0_FR]], metadata !"round.downward")
+; CHECK-NEXT: ret float [[OP]]
;
%op = call float @llvm.fptrunc.round.f32.f64(double %arg0, metadata !"round.downward")
%freeze = freeze float %op
More information about the llvm-commits
mailing list