[llvm] [Instcombine] Avoid widening trunc+sext to trunc+shl+ashr when not profitable (PR #160483)

Wenju He via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 30 04:38:33 PDT 2025


================
@@ -320,6 +320,17 @@ define i10 @test19(i10 %i) {
   ret i10 %d
 }
 
+define i32 @test20(i64 %i) {
----------------
wenju-he wrote:

> InstCombine doesn't change this test even without your patch (i16 is a legal type in this file). Please change i16 to another illegal integer type or move the test into a separate file with a suitable data layout.

thanks @dtcxzyw, I didn't notice that.
You mean i16 is not a legal type in llvm/test/Transforms/InstCombine/sext.ll, right?
I moved the test into a new file llvm/test/Transforms/InstCombine/trunc-sext.ll with native integer widths set to 16,32 and 64, and DL.isLegalInteger returns true for them.

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


More information about the llvm-commits mailing list