[all-commits] [llvm/llvm-project] 8fc9e3: [DAG] Lower frem of power-2 using div/trunc/mul+su...
David Green via All-commits
all-commits at lists.llvm.org
Fri May 10 06:59:09 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 8fc9e3d577c02d2b97c952fbafb75db0100462a9
https://github.com/llvm/llvm-project/commit/8fc9e3d577c02d2b97c952fbafb75db0100462a9
Author: David Green <david.green at arm.com>
Date: 2024-05-10 (Fri, 10 May 2024)
Changed paths:
M llvm/include/llvm/CodeGen/SelectionDAG.h
M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
M llvm/test/CodeGen/AArch64/frem-power2.ll
M llvm/test/CodeGen/ARM/frem-power2.ll
Log Message:
-----------
[DAG] Lower frem of power-2 using div/trunc/mul+sub (#91148)
If we are lowering a frem and the divisor is known to be an integer power-2, we
can use the formula 'frem = x - trunc(x / d) * d'. This avoids the more
expensive call to fmod. The results are identical as fmod so long as d is a
power-2 (so the mul does not round incorrectly), and the sign of the return is
either always positive or not important for zeroes (nsz).
Unfortunately Alive2 does not handle this well at the moment. I was using
exhaustive checking to test this:
(https://gist.github.com/davemgreen/6078015f30d3bacd1e9572f8db5d4b64).
I found this in cpythons implementation of float_pow. I currently added it as a
DAG combine for frem with power-2 fp constants.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list