[all-commits] [llvm/llvm-project] 8650f0: [InstCombine] fix miscompile when casting int->FP-...

Sanjay Patel via All-commits all-commits at lists.llvm.org
Sat May 7 05:51:05 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8650f05c97624b76fed3230bf0ea26a6106bcc3d
      https://github.com/llvm/llvm-project/commit/8650f05c97624b76fed3230bf0ea26a6106bcc3d
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2022-05-07 (Sat, 07 May 2022)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
    M llvm/test/Transforms/InstCombine/sitofp.ll

  Log Message:
  -----------
  [InstCombine] fix miscompile when casting int->FP->int

As shown in https://github.com/llvm/llvm-project/issues/55150 -
the existing fold may be wrong when converting to a signed value.
This is a quick fix to avoid the miscompile.

I added tests/comments for all of the signed/unsigned combinations
at either side of the boundary width, and tried to confirm with Alive2:
https://alive2.llvm.org/ce/z/3p9DSu

There are already some TODO items in the test file that suggest
possible refinements, so the regression with ui->FP->si is probably ok.
It seems unlikely that we'd see these kind of edge cases with
non-byte-width integer types in real code. The potential miscompile
went undetected for several years.

This and 747c6a0c734e fixes #55150.

Differential Revision: https://reviews.llvm.org/D124692




More information about the All-commits mailing list