[llvm] [Instcombine] Avoid widening trunc+sext to trunc+shl+ashr when not profitable (PR #160483)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 25 03:12:22 PDT 2025
================
@@ -0,0 +1,16 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+
+target datalayout = "i16:16:16-i32:32:32-i64:64:64-n16:32:64"
+
+define i32 @test(i64 %i) {
----------------
dtcxzyw wrote:
Can you please add a test with `trunc nsw`?
```
define i32 @test(i64 %i) {
%a = trunc nsw i64 %i to i16
%b = sext i16 %a to i32
ret i32 %b
}
```
It should be folded into `trunc nsw i64 %i to i32`.
https://github.com/llvm/llvm-project/pull/160483
More information about the llvm-commits
mailing list