[PATCH] D41603: [InstCombine] fold min/max tree with common operand (PR35717)

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 7 09:20:21 PST 2018

hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

If I'm right about the easy FP cases, I'd like to see those handled in follow-up. Regardless, this LGTM.

Comment at: lib/Transforms/InstCombine/InstCombineSelect.cpp:1297
+  assert(SelectPatternResult::isMinOrMax(SPF) && "Expected a min/max");
+  // TODO: Allow FP min/max with nnan/nsz.
+  if (!LHS->getType()->isIntOrIntVectorTy())
I think that you can easily handle most of the interesting FP cases by checking all of the select pattern results for `NaNBehavior == SPNB_NA || NaNBehavior == SPNB_RETURNS_ANY`. The other cases will require further thought (so make sure we had the correct relative ordering of all the potentially-NaN inputs).


More information about the llvm-commits mailing list