[llvm] [DAGCombiner] Freeze maybe poison operands when folding select to logic (PR #84924)
Björn Pettersson via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 20 04:50:30 PDT 2024
================
@@ -229,10 +229,41 @@ define i32 @combine_pmaddubsw_constant_sat() {
; Constant folding PMADDWD was causing an infinite loop in the PCMPGT commuting between 2 constant values.
define i1 @pmaddwd_pcmpgt_infinite_loop() {
-; CHECK-LABEL: pmaddwd_pcmpgt_infinite_loop:
-; CHECK: # %bb.0:
-; CHECK-NEXT: movb $1, %al
-; CHECK-NEXT: retq
+; SSE-LABEL: pmaddwd_pcmpgt_infinite_loop:
----------------
bjope wrote:
> Another idea then is to let DAGCombiner::visitFREEZE (or getNode for FREEZE) constant fold the operand (checking if computeKnownBits returns a constant). This to avoid that we mess up constant folding by pushing the freeze through an operation that hasn't been constant folded yet. Or is that also incorrect given that computeKnownBits has returned "known or poison"? If any constant folded value that has been derived via computeKnownBits is a possible poison value, then how can SelectionDAG::isGuaranteedNotToBeUndefOrPoison return true for constants (we can't know if a constant is a possible posion value.
To answer that myself, constant folding the freeze should be ok. But just looking through FREEZE in computeKnownBits etc is not valid.
https://github.com/llvm/llvm-project/pull/84924
More information about the llvm-commits
mailing list