Skip to content

Commit

Permalink
[InstSimplify] Add missing vector MUL tests to show lack of DemandedE…
Browse files Browse the repository at this point in the history
…lts support
  • Loading branch information
RKSimon committed Mar 19, 2020
1 parent 939ca45 commit d259e31
Showing 1 changed file with 44 additions and 3 deletions.
47 changes: 44 additions & 3 deletions llvm/test/Transforms/InstSimplify/compare.ll
Expand Up @@ -795,40 +795,81 @@ define i1 @udiv8(i32 %X, i32 %Y) {
ret i1 %C
}

; Square of a non-zero number is non-zero if there is no overflow.
define i1 @mul1(i32 %X) {
; CHECK-LABEL: @mul1(
; CHECK-NEXT: ret i1 false
;
; Square of a non-zero number is non-zero if there is no overflow.
%Y = or i32 %X, 1
%M = mul nuw i32 %Y, %Y
%C = icmp eq i32 %M, 0
ret i1 %C
}

define i1 @mul1v(<2 x i32> %X) {
; CHECK-LABEL: @mul1v(
; CHECK-NEXT: [[Y:%.*]] = or <2 x i32> [[X:%.*]], <i32 1, i32 0>
; CHECK-NEXT: [[M:%.*]] = mul nuw <2 x i32> [[Y]], [[Y]]
; CHECK-NEXT: [[E:%.*]] = extractelement <2 x i32> [[M]], i32 0
; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[E]], 0
; CHECK-NEXT: ret i1 [[C]]
;
%Y = or <2 x i32> %X, <i32 1, i32 0>
%M = mul nuw <2 x i32> %Y, %Y
%E = extractelement <2 x i32> %M, i32 0
%C = icmp eq i32 %E, 0
ret i1 %C
}

; Square of a non-zero number is positive if there is no signed overflow.
define i1 @mul2(i32 %X) {
; CHECK-LABEL: @mul2(
; CHECK-NEXT: ret i1 true
;
; Square of a non-zero number is positive if there is no signed overflow.
%Y = or i32 %X, 1
%M = mul nsw i32 %Y, %Y
%C = icmp sgt i32 %M, 0
ret i1 %C
}

define i1 @mul2v(<2 x i32> %X) {
; CHECK-LABEL: @mul2v(
; CHECK-NEXT: [[Y:%.*]] = or <2 x i32> [[X:%.*]], <i32 0, i32 1>
; CHECK-NEXT: [[M:%.*]] = mul nsw <2 x i32> [[Y]], [[Y]]
; CHECK-NEXT: [[E:%.*]] = extractelement <2 x i32> [[M]], i32 1
; CHECK-NEXT: [[C:%.*]] = icmp sgt i32 [[E]], 0
; CHECK-NEXT: ret i1 [[C]]
;
%Y = or <2 x i32> %X, <i32 0, i32 1>
%M = mul nsw <2 x i32> %Y, %Y
%E = extractelement <2 x i32> %M, i32 1
%C = icmp sgt i32 %E, 0
ret i1 %C
}

; Product of non-negative numbers is non-negative if there is no signed overflow.
define i1 @mul3(i32 %X, i32 %Y) {
; CHECK-LABEL: @mul3(
; CHECK-NEXT: ret i1 true
;
; Product of non-negative numbers is non-negative if there is no signed overflow.
%XX = mul nsw i32 %X, %X
%YY = mul nsw i32 %Y, %Y
%M = mul nsw i32 %XX, %YY
%C = icmp sge i32 %M, 0
ret i1 %C
}

define <2 x i1> @mul3v(<2 x i32> %X, <2 x i32> %Y) {
; CHECK-LABEL: @mul3v(
; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
;
%XX = mul nsw <2 x i32> %X, %X
%YY = mul nsw <2 x i32> %Y, %Y
%M = mul nsw <2 x i32> %XX, %YY
%C = icmp sge <2 x i32> %M, zeroinitializer
ret <2 x i1> %C
}

define <2 x i1> @vectorselect1(<2 x i1> %cond) {
; CHECK-LABEL: @vectorselect1(
; CHECK-NEXT: ret <2 x i1> [[COND:%.*]]
Expand Down

0 comments on commit d259e31

Please sign in to comment.