[all-commits] [llvm/llvm-project] ad5067: [InstCombine] Only fold bitcast(fptrunc) if destin...
Victor Mustya via All-commits
all-commits at lists.llvm.org
Tue Jan 16 14:13:17 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ad50676055cf03fd4fecdda5736c7ac1a940231f
https://github.com/llvm/llvm-project/commit/ad50676055cf03fd4fecdda5736c7ac1a940231f
Author: Victor Mustya <victor.mustya at intel.com>
Date: 2024-01-16 (Tue, 16 Jan 2024)
Changed paths:
M llvm/lib/IR/Instructions.cpp
M llvm/test/Transforms/InstCombine/fptrunc.ll
Log Message:
-----------
[InstCombine] Only fold bitcast(fptrunc) if destination type matches fptrunc result type. (#77046)
It's not enough to just make sure destination type is floating point,
because the following chain may be incorrectly optimized:
```LLVM
%trunc = fptrunc float %src to bfloat
%cast = bitcast bfloat %trunc to half
```
Before the fix, the instruction sequence mentioned above used to be
translated into single fptrunc instruction as follows:
```LLVM
%trunc = fptrunc float %src to half
```
Such transformation was semantically incorrect.
More information about the All-commits
mailing list