================ @@ -7054,6 +7066,30 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL, } } + // Handle trinary-op special cases. + if (NumOps == 3) { ---------------- XChy wrote: I see. Will fix it after merging the ADT change. https://github.com/llvm/llvm-project/pull/154480