[ConstantFold][SVE] Fix constant folding for scalable vector binary operations.
Summary:
Scalable vector should not be evaluated element by element.
Add support to handle scalable vector UndefValue.
Reviewers: sdesmalen, huntergr, spatel, lebedev.ri, apazos, efriedma, willlovett
Reviewed By: efriedma
Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71445
2020-01-29 10:48:57 -08:00
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2020-02-05 16:01:12 -08:00
; RUN: opt < %s -constprop -S -verify | FileCheck %s
[ConstantFold][SVE] Fix constant folding for scalable vector binary operations.
Summary:
Scalable vector should not be evaluated element by element.
Add support to handle scalable vector UndefValue.
Reviewers: sdesmalen, huntergr, spatel, lebedev.ri, apazos, efriedma, willlovett
Reviewed By: efriedma
Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71445
2020-01-29 10:48:57 -08:00
2020-01-30 10:44:20 -08:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Unary Operations
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
define < v s c a l e x 2 x double > @fneg ( < v s c a l e x 2 x double > %val ) {
; CHECK-LABEL: @fneg(
; CHECK-NEXT: ret <vscale x 2 x double> undef
;
%r = f n e g < v s c a l e x 2 x double > undef
ret < v s c a l e x 2 x double > %r
}
[ConstantFold][SVE] Fix constant folding for scalable vector binary operations.
Summary:
Scalable vector should not be evaluated element by element.
Add support to handle scalable vector UndefValue.
Reviewers: sdesmalen, huntergr, spatel, lebedev.ri, apazos, efriedma, willlovett
Reviewed By: efriedma
Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71445
2020-01-29 10:48:57 -08:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Binary Operations
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
define < v s c a l e x 4 x i32 > @add ( ) {
; CHECK-LABEL: @add(
; CHECK-NEXT: ret <vscale x 4 x i32> undef
;
%r = add < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i32 > %r
}
define < v s c a l e x 4 x float > @fadd ( ) {
; CHECK-LABEL: @fadd(
; CHECK-NEXT: ret <vscale x 4 x float> undef
;
%r = fadd < v s c a l e x 4 x float > undef , undef
ret < v s c a l e x 4 x float > %r
}
define < v s c a l e x 4 x i32 > @sub ( ) {
; CHECK-LABEL: @sub(
; CHECK-NEXT: ret <vscale x 4 x i32> undef
;
%r = sub < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i32 > %r
}
define < v s c a l e x 4 x float > @fsub ( ) {
; CHECK-LABEL: @fsub(
; CHECK-NEXT: ret <vscale x 4 x float> undef
;
%r = fsub < v s c a l e x 4 x float > undef , undef
ret < v s c a l e x 4 x float > %r
}
define < v s c a l e x 4 x i32 > @mul ( ) {
; CHECK-LABEL: @mul(
; CHECK-NEXT: ret <vscale x 4 x i32> undef
;
%r = mul < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i32 > %r
}
define < v s c a l e x 4 x float > @fmul ( ) {
; CHECK-LABEL: @fmul(
; CHECK-NEXT: ret <vscale x 4 x float> undef
;
%r = fmul < v s c a l e x 4 x float > undef , undef
ret < v s c a l e x 4 x float > %r
}
define < v s c a l e x 4 x i32 > @udiv ( ) {
; CHECK-LABEL: @udiv(
; CHECK-NEXT: ret <vscale x 4 x i32> undef
;
%r = udiv < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i32 > %r
}
define < v s c a l e x 4 x i32 > @sdiv ( ) {
; CHECK-LABEL: @sdiv(
; CHECK-NEXT: ret <vscale x 4 x i32> undef
;
%r = sdiv < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i32 > %r
}
define < v s c a l e x 4 x float > @fdiv ( ) {
; CHECK-LABEL: @fdiv(
; CHECK-NEXT: ret <vscale x 4 x float> undef
;
%r = fdiv < v s c a l e x 4 x float > undef , undef
ret < v s c a l e x 4 x float > %r
}
define < v s c a l e x 4 x i32 > @urem ( ) {
; CHECK-LABEL: @urem(
; CHECK-NEXT: ret <vscale x 4 x i32> undef
;
%r = urem < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i32 > %r
}
define < v s c a l e x 4 x i32 > @srem ( ) {
; CHECK-LABEL: @srem(
; CHECK-NEXT: ret <vscale x 4 x i32> undef
;
%r = srem < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i32 > %r
}
define < v s c a l e x 4 x float > @frem ( ) {
; CHECK-LABEL: @frem(
; CHECK-NEXT: ret <vscale x 4 x float> undef
;
%r = frem < v s c a l e x 4 x float > undef , undef
ret < v s c a l e x 4 x float > %r
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Bitwise Binary Operations
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
define < v s c a l e x 4 x i32 > @shl ( ) {
; CHECK-LABEL: @shl(
; CHECK-NEXT: ret <vscale x 4 x i32> undef
;
%r = shl < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i32 > %r
}
define < v s c a l e x 4 x i32 > @lshr ( ) {
; CHECK-LABEL: @lshr(
; CHECK-NEXT: ret <vscale x 4 x i32> undef
;
%r = lshr < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i32 > %r
}
define < v s c a l e x 4 x i32 > @ashr ( ) {
; CHECK-LABEL: @ashr(
; CHECK-NEXT: ret <vscale x 4 x i32> undef
;
%r = ashr < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i32 > %r
}
define < v s c a l e x 4 x i32 > @and ( ) {
; CHECK-LABEL: @and(
; CHECK-NEXT: ret <vscale x 4 x i32> undef
;
%r = and < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i32 > %r
}
define < v s c a l e x 4 x i32 > @or ( ) {
; CHECK-LABEL: @or(
; CHECK-NEXT: ret <vscale x 4 x i32> undef
;
%r = or < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i32 > %r
}
define < v s c a l e x 4 x i32 > @xor ( ) {
; CHECK-LABEL: @xor(
; CHECK-NEXT: ret <vscale x 4 x i32> zeroinitializer
;
%r = xor < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i32 > %r
}
2020-01-30 10:49:10 -08:00
2020-02-05 16:01:12 -08:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Vector Operations
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
define < v s c a l e x 4 x i32 > @insertelement ( ) {
; CHECK-LABEL: @insertelement(
; CHECK-NEXT: ret <vscale x 4 x i32> insertelement (<vscale x 4 x i32> undef, i32 1, i32 0)
;
%i = insertelement < v s c a l e x 4 x i32 > undef , i32 1 , i32 0
ret < v s c a l e x 4 x i32 > %i
}
define < v s c a l e x 4 x i32 > @shufflevector ( ) {
; CHECK-LABEL: @shufflevector(
; CHECK-NEXT: ret <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> undef, i32 1, i32 0), <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer)
;
%i = insertelement < v s c a l e x 4 x i32 > undef , i32 1 , i32 0
%i2 = shufflevector < v s c a l e x 4 x i32 > %i , < v s c a l e x 4 x i32 > undef , < v s c a l e x 4 x i32 > zeroinitializer
ret < v s c a l e x 4 x i32 > %i2
}
2020-02-12 10:19:03 -08:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Memory Access and Addressing Operations
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
define < v s c a l e x 2 x double > @load ( ) {
; CHECK-LABEL: @load(
; CHECK-NEXT: [[R:%.*]] = load <vscale x 2 x double>, <vscale x 2 x double>* getelementptr (<vscale x 2 x double>, <vscale x 2 x double>* null, i64 1)
; CHECK-NEXT: ret <vscale x 2 x double> [[R]]
;
%r = load < v s c a l e x 2 x double > , < v s c a l e x 2 x double > * getelementptr ( < v s c a l e x 2 x double > , < v s c a l e x 2 x double > * null , i64 1 )
ret < v s c a l e x 2 x double > %r
}
2020-02-05 16:01:12 -08:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Conversion Operations
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
define < v s c a l e x 4 x float > @bitcast ( ) {
; CHECK-LABEL: @bitcast(
; CHECK-NEXT: ret <vscale x 4 x float> bitcast (<vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> undef, i32 1, i32 0), <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer) to <vscale x 4 x float>)
;
%i1 = insertelement < v s c a l e x 4 x i32 > undef , i32 1 , i32 0
%i2 = shufflevector < v s c a l e x 4 x i32 > %i1 , < v s c a l e x 4 x i32 > undef , < v s c a l e x 4 x i32 > zeroinitializer
%i3 = bitcast < v s c a l e x 4 x i32 > %i2 to < v s c a l e x 4 x float >
ret < v s c a l e x 4 x float > %i3
}
2020-01-30 10:49:10 -08:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Other Operations
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
define < v s c a l e x 4 x i32 > @select ( ) {
; CHECK-LABEL: @select(
; CHECK-NEXT: ret <vscale x 4 x i32> undef
;
%r = select < v s c a l e x 4 x i1 > undef , < v s c a l e x 4 x i32 > zeroinitializer , < v s c a l e x 4 x i32 > undef
ret < v s c a l e x 4 x i32 > %r
}
2020-02-11 14:04:45 -08:00
declare < v s c a l e x 16 x i8 > @llvm.sadd.sat.nxv16i8 ( < v s c a l e x 16 x i8 > , < v s c a l e x 16 x i8 > )
define < v s c a l e x 16 x i8 > @call ( ) {
; CHECK-LABEL: @call(
; CHECK-NEXT: [[R:%.*]] = call <vscale x 16 x i8> @llvm.sadd.sat.nxv16i8(<vscale x 16 x i8> undef, <vscale x 16 x i8> undef)
; CHECK-NEXT: ret <vscale x 16 x i8> [[R]]
;
%r = call < v s c a l e x 16 x i8 > @llvm.sadd.sat.nxv16i8 ( < v s c a l e x 16 x i8 > undef , < v s c a l e x 16 x i8 > undef )
ret < v s c a l e x 16 x i8 > %r
}
2020-03-12 15:59:14 -07:00
define < v s c a l e x 4 x i1 > @icmp_undef ( ) {
; CHECK-LABEL: @icmp_undef(
; CHECK-NEXT: ret <vscale x 4 x i1> undef
;
%r = icmp eq < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i1 > %r
}
define < v s c a l e x 4 x i1 > @icmp_zero ( ) {
; CHECK-LABEL: @icmp_zero(
; CHECK-NEXT: ret <vscale x 4 x i1> icmp eq (<vscale x 4 x i32> zeroinitializer, <vscale x 4 x i32> zeroinitializer)
;
%r = icmp eq < v s c a l e x 4 x i32 > zeroinitializer , zeroinitializer
ret < v s c a l e x 4 x i1 > %r
}
define < v s c a l e x 4 x i1 > @fcmp_true ( ) {
; CHECK-LABEL: @fcmp_true(
; CHECK-NEXT: ret <vscale x 4 x i1> shufflevector (<vscale x 4 x i1> insertelement (<vscale x 4 x i1> undef, i1 true, i32 0), <vscale x 4 x i1> undef, <vscale x 4 x i32> zeroinitializer)
;
%r = fcmp true < v s c a l e x 4 x float > undef , undef
ret < v s c a l e x 4 x i1 > %r
}
define < v s c a l e x 4 x i1 > @fcmp_false ( ) {
; CHECK-LABEL: @fcmp_false(
; CHECK-NEXT: ret <vscale x 4 x i1> zeroinitializer
;
%r = fcmp false < v s c a l e x 4 x float > undef , undef
ret < v s c a l e x 4 x i1 > %r
}
define < v s c a l e x 4 x i1 > @fcmp_undef ( ) {
; CHECK-LABEL: @fcmp_undef(
; CHECK-NEXT: ret <vscale x 4 x i1> undef
;
%r = icmp ne < v s c a l e x 4 x i32 > undef , undef
ret < v s c a l e x 4 x i1 > %r
}
define < v s c a l e x 4 x i1 > @fcmp_not_equality ( ) {
; CHECK-LABEL: @fcmp_not_equality(
; CHECK-NEXT: ret <vscale x 4 x i1> shufflevector (<vscale x 4 x i1> insertelement (<vscale x 4 x i1> undef, i1 true, i32 0), <vscale x 4 x i1> undef, <vscale x 4 x i32> zeroinitializer)
;
%r = icmp ule < v s c a l e x 4 x i32 > undef , zeroinitializer
ret < v s c a l e x 4 x i1 > %r
}