[PATCH] D142093: [InstCombine] trunc (fptoui|fptosi)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 20 11:26:50 PST 2023


spatel added a comment.

I updated the test file; see if this covers everything for fptoui:
cb29ba9c0f87 <https://reviews.llvm.org/rGcb29ba9c0f8726d768caff29f7c400c19774cbd8>
(if yes, then we duplicate each test for fptoui with one extra bit for the integer types)



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:503-506
+    uint32_t MinBitWidth = InputTy->getScalarSizeInBits() + 1;
+    if (InputTy->isHalfTy() && I->getOpcode() == Instruction::FPToUI)
+      MinBitWidth = 16;
+    return BitWidth >= MinBitWidth;
----------------
This isn't correct - we want to use semanticsMaxExponent() or something like that to determine the minimum bitwidth. Signed cast needs one extra bit to not truncate the sign bit in integer form.


================
Comment at: llvm/test/Transforms/InstCombine/trunc-fp-to-int.ll:160
 
 define i33 @float_fptoui_i64_i33(float %x) {
 ; CHECK-LABEL: @float_fptoui_i64_i33(
----------------
This and the following tests are miscompiles (noundef is used here only to prevent the timeout):
https://alive2.llvm.org/ce/z/UCo_Py


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142093/new/

https://reviews.llvm.org/D142093



More information about the llvm-commits mailing list