[PATCH] D38421: Eliminate ftrunc if source is know to be rounded

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 29 13:27:10 PDT 2017


rampitec added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:10705
 
+  // fold ftrunc (known rounded int x) -> x
+  switch (N0.getOpcode()) {
----------------
hfinkel wrote:
> Is there any way we can generalize this? All of the operations listed here are like ftrunc in this regard (they're idempotent for integer inputs).
> 
I did not find any function to tell if a value is rounded to integer. Thinking about that function it might be non-trivial, given that we might have denorms. So I decided to go with opcodes which guarantied to produce integral value no matter what. A function like that most likely shall also check for these opcodes first before taking more complex analysis.


https://reviews.llvm.org/D38421





More information about the llvm-commits mailing list