[PATCH] D45862: [InstCombine] Relax restriction in foldSelectInstWithICmp for sake of smaller code size

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 20 11:01:55 PDT 2018


lebedev.ri added a comment.

Other than that inline comment, i think it would be nice to commit
the baseline tests (as of trunk), so the effect of this proposal could be observed.
Even if the code changes won't land, this would at least document the current behavior.



================
Comment at: test/Transforms/InstCombine/select-of-bittest.ll:660
+
+define i32 @compare_to_zero_mismatched_types_idiomatic_trunc(i64 %x) {
+; CHECK-LABEL: @compare_to_zero_mismatched_types_idiomatic_trunc(
----------------
lebedev.ri wrote:
> For each of those, could you please add vector tests.
> Something like:
> ```
> define i32 @compare_to_zero_mismatched_types_idiomatic_trunc(i64 %x) {
>   %cmp = icmp slt i64 %x, 0
>   %select1 = select i1 %cmp, i32 -1, i32 1
>   ret i32 %select1
> }
> 
> define <2 x i32> @compare_to_zero_mismatched_types_idiomatic_trunc_splatvec(<2 x i64> %x) {
>   %cmp = icmp slt <2 x i64> %x, <i64 0, i64 0>
>   %select1 = select <2 x i1> %cmp, <i32 -1, i32 -1>, <i32 1, i32 1>
>   ret <2 x i32> %select1
> }
> 
> define <3 x i32> @compare_to_zero_mismatched_types_idiomatic_trunc_splatvec_undef(<3 x i64> %x) {
>   %cmp = icmp slt <3 x i64> %x, <i64 0, i64 undef, i64 0>
>   %select1 = select <3 x i1> %cmp, <i32 -1, i64 undef, i32 -1>, <i32 1, i64 undef, i32 1>
>   ret <3 x i32> %select1
> }
> 
> ; May be more than one
> define <3 x i32> @compare_to_zero_mismatched_types_idiomatic_trunc_nonsplatvec(<3 x i64> %x) {
>   %cmp = icmp slt <3 x i64> %x, <i64 0, i64 undef, i64 0>
>   %select1 = select <3 x i1> %cmp, <i32 -1, i64 0, i32 1>, <i32 1, i64 0, i32 -1>
>   ret <3 x i32> %select1
> }
> ```
> 
Oh, also, this is a **really** bad place to add these tests.
They should either go to a new file, or at least before
```
; ============================================================================ ;
; Negative tests. Should not be folded.
; ============================================================================ ;
```



https://reviews.llvm.org/D45862





More information about the llvm-commits mailing list