[PATCH] D92270: [ConstantFold] Fold more operations to poison

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 15 07:57:38 PST 2021


spatel added inline comments.


================
Comment at: llvm/lib/IR/ConstantFold.cpp:633
         // the input constant.
-        return UndefValue::get(DestTy);
+        return PoisonValue::get(DestTy);
       }
----------------
aqjune wrote:
> neildhar wrote:
> > spatel wrote:
> > > MatzeB wrote:
> > > > I believe this is causing some of our clients trouble, especially since we somehow have a `-fno-strict-float-cast-overflow` flag in clang that says float->int overflows are not UB... (CC @spatel )
> > > I can guess at what the example looks like, but it would be great to have a reduced test.
> > > There should be a function attribute in IR corresponding to that clang flag, so we could alter the behavior here based on checking that? Not sure if there's precedence for that kind of transform though.
> > Here's a minimal repro for the issue we ran into: https://godbolt.org/z/Wdr7q1a9M
> Clang is lowering fp-to-int casts into fptosi/ui (https://godbolt.org/z/Gz3Y7YKKf), but I think in this case clang must emit the fptosi.sat intrinsic: 
> https://llvm.org/docs/LangRef.html#llvm-fptosi-sat-intrinsic
> It guarantees that the result is well-defined.
I agree with this suggestion. Here's a patch proposal:
D115804


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92270



More information about the llvm-commits mailing list