[llvm] [DAG] Add TRUNCATE_SSAT_S/U and TRUNCATE_USAT_U to canCreateUndefOrPoison (#152143) (PR #168809)
Jerry Dang via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 20 11:41:34 PST 2025
================
@@ -0,0 +1,64 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s
+
+; Test that freeze is eliminated for saturation truncate patterns.
+; The freeze elimination happens at the IR level due to the IntrNoCreateUndefOrPoison
+; attribute on the llvm.smax/smin/umin intrinsics. At the SelectionDAG level,
+; TRUNCATE_SSAT_S/U and TRUNCATE_USAT_U operations are also marked in
+; canCreateUndefOrPoison() to ensure consistency and enable potential future
+; optimizations. This test validates the end-to-end behavior that no freeze
+; instruction appears in the output.
----------------
kuroyukiasuna wrote:
I tried several test patterns to show visible codegen differences:
- Comparison with out-of-range values (should fold to constant)
- Redundant min/max operations (should be eliminated)
- KnownBits patterns with AND/zext
None produced different assembly with/without the change, though the DAG optimization does occur.
https://github.com/llvm/llvm-project/pull/168809
More information about the llvm-commits
mailing list