Skip to content

Commit

Permalink
[InstCombine] Fix commuted tests (NFC)
Browse files Browse the repository at this point in the history
Make sure complexity-based canonicalization doesn't get in the
way.
  • Loading branch information
nikic committed Aug 29, 2023
1 parent 125abbd commit 5f9b4bc
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions llvm/test/Transforms/InstCombine/select-and-or.ll
Original file line number Diff line number Diff line change
Expand Up @@ -628,26 +628,30 @@ define i1 @or_and2(i1 %a, i1 %b, i1 %c) {
ret i1 %r
}

define i1 @or_and1_commuted(i1 %a, i1 %b, i1 %c) {
define i1 @or_and1_commuted(i1 %a, i1 %b) {
; CHECK-LABEL: @or_and1_commuted(
; CHECK-NEXT: [[C:%.*]] = call i1 @gen_i1()
; CHECK-NEXT: [[NOTB:%.*]] = xor i1 [[B:%.*]], true
; CHECK-NEXT: [[COND:%.*]] = and i1 [[NOTB]], [[C:%.*]]
; CHECK-NEXT: [[COND:%.*]] = and i1 [[C]], [[NOTB]]
; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A:%.*]], i1 [[B]]
; CHECK-NEXT: ret i1 [[R]]
;
%c = call i1 @gen_i1()
%notb = xor i1 %b, true
%cond = and i1 %c, %notb
%r = select i1 %cond, i1 %a, i1 %b
ret i1 %r
}

define i1 @or_and2_commuted(i1 %a, i1 %b, i1 %c) {
define i1 @or_and2_commuted(i1 %b, i1 %c) {
; CHECK-LABEL: @or_and2_commuted(
; CHECK-NEXT: [[A:%.*]] = call i1 @gen_i1()
; CHECK-NEXT: [[NOTC:%.*]] = xor i1 [[C:%.*]], true
; CHECK-NEXT: [[COND:%.*]] = or i1 [[NOTC]], [[A:%.*]]
; CHECK-NEXT: [[COND:%.*]] = or i1 [[A]], [[NOTC]]
; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A]], i1 [[B:%.*]]
; CHECK-NEXT: ret i1 [[R]]
;
%a = call i1 @gen_i1()
%notc = xor i1 %c, true
%cond = or i1 %a, %notc
%r = select i1 %cond, i1 %a, i1 %b
Expand Down Expand Up @@ -684,32 +688,28 @@ define i1 @or_and2_multiuse(i1 %a, i1 %b, i1 %c) {
ret i1 %r
}

define <2 x i1> @or_and1_vec(<2 x i1> %a, <2 x i1> %b) {
define <2 x i1> @or_and1_vec(<2 x i1> %a, <2 x i1> %b, <2 x i1> %c) {
; CHECK-LABEL: @or_and1_vec(
; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()
; CHECK-NEXT: [[NOTB:%.*]] = xor <2 x i1> [[B:%.*]], <i1 true, i1 true>
; CHECK-NEXT: [[COND:%.*]] = and <2 x i1> [[C]], [[NOTB]]
; CHECK-NEXT: [[COND:%.*]] = and <2 x i1> [[NOTB]], [[C:%.*]]
; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[COND]], <2 x i1> [[A:%.*]], <2 x i1> [[B]]
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%c = call <2 x i1> @gen_v2i1()
%notb = xor <2 x i1> %b, <i1 true, i1 true>
%cond = and <2 x i1> %c, %notb
%cond = and <2 x i1> %notb, %c
%r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b
ret <2 x i1> %r
}

define <2 x i1> @or_and2_vec(<2 x i1> %a, <2 x i1> %b) {
define <2 x i1> @or_and2_vec(<2 x i1> %a, <2 x i1> %b, <2 x i1> %c) {
; CHECK-LABEL: @or_and2_vec(
; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()
; CHECK-NEXT: [[NOTC:%.*]] = xor <2 x i1> [[C]], <i1 true, i1 true>
; CHECK-NEXT: [[NOTC:%.*]] = xor <2 x i1> [[C:%.*]], <i1 true, i1 true>
; CHECK-NEXT: [[COND:%.*]] = or <2 x i1> [[NOTC]], [[A:%.*]]
; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[COND]], <2 x i1> [[A]], <2 x i1> [[B:%.*]]
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%c = call <2 x i1> @gen_v2i1()
%notc = xor <2 x i1> %c, <i1 true, i1 true>
%cond = or <2 x i1> %a, %notc
%cond = or <2 x i1> %notc, %a
%r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b
ret <2 x i1> %r
}
Expand All @@ -724,22 +724,22 @@ define <2 x i1> @or_and1_vec_commuted(<2 x i1> %a, <2 x i1> %b) {
;
%c = call <2 x i1> @gen_v2i1()
%notb = xor <2 x i1> %b, <i1 true, i1 true>
%cond = and <2 x i1> %notb, %c
%cond = and <2 x i1> %c, %notb
%r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b
ret <2 x i1> %r
}

define <2 x i1> @or_and2_vec_commuted(<2 x i1> %a, <2 x i1> %b) {
define <2 x i1> @or_and2_vec_commuted(<2 x i1> %b, <2 x i1> %c) {
; CHECK-LABEL: @or_and2_vec_commuted(
; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()
; CHECK-NEXT: [[NOTC:%.*]] = xor <2 x i1> [[C]], <i1 true, i1 true>
; CHECK-NEXT: [[COND:%.*]] = or <2 x i1> [[NOTC]], [[A:%.*]]
; CHECK-NEXT: [[A:%.*]] = call <2 x i1> @gen_v2i1()
; CHECK-NEXT: [[NOTC:%.*]] = xor <2 x i1> [[C:%.*]], <i1 true, i1 true>
; CHECK-NEXT: [[COND:%.*]] = or <2 x i1> [[A]], [[NOTC]]
; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[COND]], <2 x i1> [[A]], <2 x i1> [[B:%.*]]
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%c = call <2 x i1> @gen_v2i1()
%a = call <2 x i1> @gen_v2i1()
%notc = xor <2 x i1> %c, <i1 true, i1 true>
%cond = or <2 x i1> %notc, %a
%cond = or <2 x i1> %a, %notc
%r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b
ret <2 x i1> %r
}
Expand Down

0 comments on commit 5f9b4bc

Please sign in to comment.