[llvm] [DAGCombiner] Preserve nsw when folding (mul x, 2^c) to (shl x, c) (PR #192366)

Jim Lin via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 23:08:00 PDT 2026


================
@@ -0,0 +1,40 @@
+; REQUIRES: asserts
+; RUN: llc -mtriple=riscv64 -debug-only=isel -o /dev/null %s 2>&1 | FileCheck %s
+
+; Verify that DAGCombiner's (mul x, 2^c) -> (shl x, c) fold preserves the nsw
+; flag when the shift amount is strictly less than BitWidth - 1, and does not
+; preserve it when the multiplier is the signed minimum (2^(BitWidth - 1)).
+; RISC-V has no unified IMUL-with-flags instruction, so this inspects the
----------------
tclin914 wrote:

Remove it

https://github.com/llvm/llvm-project/pull/192366


More information about the llvm-commits mailing list