[PATCH] D43172: [SelectionDAG][ARM][X86] Teach PromoteIntRes_SETCC to do a better job picking the result type for the setcc.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 15 14:56:29 PDT 2018


craig.topper added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:604
+      // Input type isn't promoted, just use the default promoted type.
+      SVT = NVT;
+    }
----------------
efriedma wrote:
> Are you intentionally changing the behavior in the case where SVT is an illegal type which won't be promoted?
Yes. I think the getSetccResultType is a good answer if it doesn't need to be promoted.

This is what happened in the X86 test case that changed:

getSetccResultType for v8i64 returned v8i64, but the original code detected it as an illegal type and instead changed it to v8i16 creating a weird looking (v8i16 (setcc (v8i64))). Now type legalization splits the input type. And creates (v8i16 (sext (concat_vectors (v4i1 (setcc (v4i64))), (v4i1 (setcc (v4i64)))).   The v4i1 setccs try to legalize their result types. We call getSetCCResultType and get v4i64 reject it as illegal and use v4i32. Creating another pair of weird setccs that have to be split and promoted.

If we had keep the original v8i64 answer from getSetccResultType we would have create a normal looking (v8i64 (setcc (v8i64))). Then split that to (v4i64 (setcc (v4i64))) and then (v2i64 (setcc (v2i64))) without any intermediate promotions of the setccs.

We are still doing something weird with v2f32 setccs on x86. We call getSetccResultType and get v2i32, which needs to be promoted, but v2f32 doesn't need to be promoted. So we fall back to using NVT(v2i64) and create (v2i64 (setcc v2f32)). Which we widen and create (v2i64 (sext (v2i32 (extract_subvector (v4i32 (setcc v432)))).


https://reviews.llvm.org/D43172





More information about the llvm-commits mailing list