I think this is safe as long as no inputs are known to ever be nans.
Also add an intrinsic for fmed3 to be able to handle all safe math cases.
Paths 
  |  Differential  D28833  
AMDGPU: Generalize matching of v_med3_f32 ClosedPublic Authored by arsenm on Jan 17 2017, 4:06 PM. 
Details 
 Summary I think this is safe as long as no inputs are known to ever be nans. Also add an intrinsic for fmed3 to be able to handle all safe math cases. 
Diff Detail 
Revision Contents 
 
Diff 84763 include/llvm/IR/IntrinsicsAMDGPU.td
 lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
 lib/Target/AMDGPU/AMDGPUInstructions.td
 lib/Target/AMDGPU/SIISelLowering.cpp
 lib/Target/AMDGPU/SIInstrInfo.td
 lib/Target/AMDGPU/SIInstructions.td
 test/CodeGen/AMDGPU/fmed3.ll
 test/CodeGen/AMDGPU/llvm.amdgcn.fmed3.ll
 
  | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||