In the aftermath of the reversion of http://reviews.llvm.org/rL236031 (D9232), nobody said this idea was outright crazy...so I'm trying again. :)
This time, I've added a bunch of safety measures:
- Target-dependent and opt-in per target; currently only x86
- A map to count and limit the number of times we try this transform
- Only attempt after type legalization
- x86 FADD limit artificially low until we're sure there's no fallout
I ended up with target hooks (shouldReassociate / didReassociate) similar to what Jon suggested in a reply mail to r236031.
There are a bunch of TODO items to make this better, but I'm purposely starting as small as possible.
I initially thought that the tracking map should live in X86TargetLowering with the hooks, but that doesn't seem in tune with the rest of the class (it's all const AFAICT), and the target outlives the Combiner or DAG, so the map would need to be reset before each combine if it lived there?