From da9c0e77d9b70a42caea0bbdeea435a021ee27e2 Mon Sep 17 00:00:00 2001 From: Violet Date: Tue, 23 Sep 2025 18:16:03 +0000 Subject: [PATCH] Improve constant folding for sign extension --- ptx/lib/zluda_ptx_impl.bc | Bin 24796 -> 24896 bytes ptx/lib/zluda_ptx_impl.cpp | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ptx/lib/zluda_ptx_impl.bc b/ptx/lib/zluda_ptx_impl.bc index b89e0d120aa69ba530b9a6a739cdbc6d1dcf250e..afc9c2c502e413f473ecd473e5f781656d4a9e4c 100644 GIT binary patch delta 303 zcmca}knzAF#tABn=QgV53Ny)QZJr{0$F$ysfq_Ao#ZgCqfq{XSfq}t9qf|`d7T38NcAwrZ2-w{V3e36J%usu09zHK^c%?>uyn!%HuDBA zsXGTa4=Sm$n-@535U;RKDqv9LU=!AUaZrxsFmGA{dqTk>=@%u=1{{ZZ6DP1I7~EO# zl2L-k+^3p>?J{q%0{g*|W|<=g3!F9xU*;_mU_ZurP)_)TX7K`bmfegDn`OQBiva** CU1fRz delta 202 zcmX?bi1E%r#tABnTQ{oa3N!U+Y@Q-~$FyFXfq_Ao#ZgCqfq{XKfq}t9qy3PEgM-74 zCJhINIZhf5eS!^4A{q`8m{?R+I5;?TaIvtkv}iau{Ap)mVR6xL_}BbNo`Hcu-L)#X zMBJq+6ht_0X!k5{Tw=~r?YK#qja{HA!C=LJx}ztM zkx-C4;bnpIfyRSV8!_&}qYE-dpW+1l~9{#vOjic`$Etqt|{h E0L~Fb(s >> (i * 4)); uint8_t addr = sel & 0x7; + if (sel & 0x8) + { + if (addr % 2 == 1) + { + v_perm_selector.u8x4[i] = 0x8 + addr / 2; + continue; + } + } v_perm_selector.u8x4[i] = addr; } @@ -821,9 +829,14 @@ typedef uint32_t ShflSyncResult __attribute__((ext_vector_type(2))); for (size_t i = 0; i < 4; i++) { uint8_t sel = static_cast(s >> (i * 4)); + uint8_t addr = sel & 0x7; if (sel & 0x8) { - output.u8x4[i] = (output.u8x4[i] & 0x80) * 0xff; + if (addr % 2 != 1) + { + output.u8x4[i] = (output.u8x4[i] & 0x80) * 0xff; + continue; + } } }