[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:19:19 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:
> All computeKnownBits() style APIs return "known or poison" results. It's not possible for look through freeze.
Right. Hm. And pushing freeze through operations aggressively/early might block other simplifications as in the example with lshr (which is why we currently avoid it for SRA and SRL).
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.
https://github.com/llvm/llvm-project/pull/84924
More information about the llvm-commits
mailing list