[InstCombine] Add test cases showing failures to handle commuted patterns after tricking the operand complexity sorting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301296 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2017-04-25 06:22:17 +00:00
parent 0e5fc34d70
commit 17d26f1cbf

View File

@ -613,3 +613,37 @@ final:
%value = and <2 x i32> %A, <i32 123, i32 333>
ret <2 x i32> %value
}
define i32 @test42(i32 %a, i32 %c, i32 %d) {
; CHECK-LABEL: @test42(
; CHECK-NEXT: [[FORCE:%.*]] = mul i32 [[C:%.*]], [[D:%.*]]
; CHECK-NEXT: [[OR:%.*]] = or i32 [[FORCE]], [[A:%.*]]
; CHECK-NEXT: [[NOTA:%.*]] = xor i32 [[A]], -1
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[FORCE]], [[NOTA]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[XOR]], [[OR]]
; CHECK-NEXT: ret i32 [[AND]]
;
%force = mul i32 %c, %d ; forces the complexity sorting
%or = or i32 %a, %force
%nota = xor i32 %a, -1
%xor = xor i32 %nota, %force
%and = and i32 %xor, %or
ret i32 %and
}
define i32 @test43(i32 %a, i32 %c, i32 %d) {
; CHECK-LABEL: @test43(
; CHECK-NEXT: [[FORCE:%.*]] = mul i32 [[C:%.*]], [[D:%.*]]
; CHECK-NEXT: [[OR:%.*]] = or i32 [[FORCE]], [[A:%.*]]
; CHECK-NEXT: [[NOTA:%.*]] = xor i32 [[A]], -1
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[FORCE]], [[NOTA]]
; CHECK-NEXT: [[AND:%.*]] = and i32 [[OR]], [[XOR]]
; CHECK-NEXT: ret i32 [[AND]]
;
%force = mul i32 %c, %d ; forces the complexity sorting
%or = or i32 %a, %force
%nota = xor i32 %a, -1
%xor = xor i32 %nota, %force
%and = and i32 %or, %xor
ret i32 %and
}