[llvm] 4bb7b6f - [IR] Remove support for float binop constant expressions
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 12 00:40:59 PDT 2022
Author: Nikita Popov
Date: 2022-07-12T09:40:49+02:00
New Revision: 4bb7b6fae3be02031878b2aa3be584c6627ad8ec
URL: https://github.com/llvm/llvm-project/commit/4bb7b6fae3be02031878b2aa3be584c6627ad8ec
DIFF: https://github.com/llvm/llvm-project/commit/4bb7b6fae3be02031878b2aa3be584c6627ad8ec.diff
LOG: [IR] Remove support for float binop constant expressions
As part of https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179,
this removes support for the floating-point binop constant expressions
fadd, fsub, fmul, fdiv and frem.
As part of this change, the C APIs LLVMConstFAdd, LLVMConstFSub,
LLVMConstFMul, LLVMConstFDiv and LLVMConstFRem are removed.
The LLVMBuild APIs should be used instead.
Differential Revision: https://reviews.llvm.org/D129478
Added:
Modified:
llvm/bindings/go/llvm/ir.go
llvm/bindings/ocaml/llvm/llvm.ml
llvm/bindings/ocaml/llvm/llvm.mli
llvm/docs/ReleaseNotes.rst
llvm/include/llvm-c/Core.h
llvm/include/llvm/IR/Constants.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/IR/Core.cpp
llvm/test/Bindings/OCaml/core.ml
llvm/test/CodeGen/AMDGPU/sched-crash-dbg-value.mir
llvm/test/CodeGen/AMDGPU/si-spill-cf.ll
llvm/test/CodeGen/PowerPC/2008-07-15-Fabs.ll
llvm/test/CodeGen/X86/2011-02-23-UnfoldBug.ll
llvm/test/CodeGen/X86/pr44749.ll
llvm/test/DebugInfo/ARM/selectiondag-deadcode.ll
llvm/test/Transforms/InstCombine/fma.ll
llvm/test/Transforms/InstCombine/fmul.ll
llvm/test/Transforms/InstSimplify/ConstProp/bitcast.ll
llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll
llvm/test/Transforms/InstSimplify/fdiv.ll
llvm/test/Transforms/LoopVectorize/scev-exitlim-crash.ll
llvm/unittests/IR/ConstantsTest.cpp
Removed:
################################################################################
diff --git a/llvm/bindings/go/llvm/ir.go b/llvm/bindings/go/llvm/ir.go
index 471da8463cb12..fef7f011b3d07 100644
--- a/llvm/bindings/go/llvm/ir.go
+++ b/llvm/bindings/go/llvm/ir.go
@@ -909,17 +909,12 @@ func ConstNot(v Value) (rv Value) { rv.C = C.LLVMConstNot(v.C); retu
func ConstAdd(lhs, rhs Value) (v Value) { v.C = C.LLVMConstAdd(lhs.C, rhs.C); return }
func ConstNSWAdd(lhs, rhs Value) (v Value) { v.C = C.LLVMConstNSWAdd(lhs.C, rhs.C); return }
func ConstNUWAdd(lhs, rhs Value) (v Value) { v.C = C.LLVMConstNUWAdd(lhs.C, rhs.C); return }
-func ConstFAdd(lhs, rhs Value) (v Value) { v.C = C.LLVMConstFAdd(lhs.C, rhs.C); return }
func ConstSub(lhs, rhs Value) (v Value) { v.C = C.LLVMConstSub(lhs.C, rhs.C); return }
func ConstNSWSub(lhs, rhs Value) (v Value) { v.C = C.LLVMConstNSWSub(lhs.C, rhs.C); return }
func ConstNUWSub(lhs, rhs Value) (v Value) { v.C = C.LLVMConstNUWSub(lhs.C, rhs.C); return }
-func ConstFSub(lhs, rhs Value) (v Value) { v.C = C.LLVMConstFSub(lhs.C, rhs.C); return }
func ConstMul(lhs, rhs Value) (v Value) { v.C = C.LLVMConstMul(lhs.C, rhs.C); return }
func ConstNSWMul(lhs, rhs Value) (v Value) { v.C = C.LLVMConstNSWMul(lhs.C, rhs.C); return }
func ConstNUWMul(lhs, rhs Value) (v Value) { v.C = C.LLVMConstNUWMul(lhs.C, rhs.C); return }
-func ConstFMul(lhs, rhs Value) (v Value) { v.C = C.LLVMConstFMul(lhs.C, rhs.C); return }
-func ConstFDiv(lhs, rhs Value) (v Value) { v.C = C.LLVMConstFDiv(lhs.C, rhs.C); return }
-func ConstFRem(lhs, rhs Value) (v Value) { v.C = C.LLVMConstFRem(lhs.C, rhs.C); return }
func ConstAnd(lhs, rhs Value) (v Value) { v.C = C.LLVMConstAnd(lhs.C, rhs.C); return }
func ConstOr(lhs, rhs Value) (v Value) { v.C = C.LLVMConstOr(lhs.C, rhs.C); return }
func ConstXor(lhs, rhs Value) (v Value) { v.C = C.LLVMConstXor(lhs.C, rhs.C); return }
diff --git a/llvm/bindings/ocaml/llvm/llvm.ml b/llvm/bindings/ocaml/llvm/llvm.ml
index 19603b97a8738..cabfd4ec63037 100644
--- a/llvm/bindings/ocaml/llvm/llvm.ml
+++ b/llvm/bindings/ocaml/llvm/llvm.ml
@@ -642,17 +642,12 @@ external const_not : llvalue -> llvalue = "LLVMConstNot"
external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
external const_nsw_add : llvalue -> llvalue -> llvalue = "LLVMConstNSWAdd"
external const_nuw_add : llvalue -> llvalue -> llvalue = "LLVMConstNUWAdd"
-external const_fadd : llvalue -> llvalue -> llvalue = "LLVMConstFAdd"
external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
external const_nsw_sub : llvalue -> llvalue -> llvalue = "LLVMConstNSWSub"
external const_nuw_sub : llvalue -> llvalue -> llvalue = "LLVMConstNUWSub"
-external const_fsub : llvalue -> llvalue -> llvalue = "LLVMConstFSub"
external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
external const_nsw_mul : llvalue -> llvalue -> llvalue = "LLVMConstNSWMul"
external const_nuw_mul : llvalue -> llvalue -> llvalue = "LLVMConstNUWMul"
-external const_fmul : llvalue -> llvalue -> llvalue = "LLVMConstFMul"
-external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
-external const_frem : llvalue -> llvalue -> llvalue = "LLVMConstFRem"
external const_and : llvalue -> llvalue -> llvalue = "LLVMConstAnd"
external const_or : llvalue -> llvalue -> llvalue = "LLVMConstOr"
external const_xor : llvalue -> llvalue -> llvalue = "LLVMConstXor"
diff --git a/llvm/bindings/ocaml/llvm/llvm.mli b/llvm/bindings/ocaml/llvm/llvm.mli
index 4ce883ab1d1e8..b41d69e60cebd 100644
--- a/llvm/bindings/ocaml/llvm/llvm.mli
+++ b/llvm/bindings/ocaml/llvm/llvm.mli
@@ -1099,10 +1099,6 @@ val const_nsw_add : llvalue -> llvalue -> llvalue
See the method [llvm::ConstantExpr::getNSWAdd]. *)
val const_nuw_add : llvalue -> llvalue -> llvalue
-(** [const_fadd c1 c2] returns the constant sum of two constant floats.
- See the method [llvm::ConstantExpr::getFAdd]. *)
-val const_fadd : llvalue -> llvalue -> llvalue
-
(** [const_sub c1 c2] returns the constant
diff erence, [c1 - c2], of two
constants. See the method [llvm::ConstantExpr::getSub]. *)
val const_sub : llvalue -> llvalue -> llvalue
@@ -1117,10 +1113,6 @@ val const_nsw_sub : llvalue -> llvalue -> llvalue
See the method [llvm::ConstantExpr::getNSWSub]. *)
val const_nuw_sub : llvalue -> llvalue -> llvalue
-(** [const_fsub c1 c2] returns the constant
diff erence, [c1 - c2], of two
- constant floats. See the method [llvm::ConstantExpr::getFSub]. *)
-val const_fsub : llvalue -> llvalue -> llvalue
-
(** [const_mul c1 c2] returns the constant product of two constants.
See the method [llvm::ConstantExpr::getMul]. *)
val const_mul : llvalue -> llvalue -> llvalue
@@ -1135,20 +1127,6 @@ val const_nsw_mul : llvalue -> llvalue -> llvalue
See the method [llvm::ConstantExpr::getNSWMul]. *)
val const_nuw_mul : llvalue -> llvalue -> llvalue
-(** [const_fmul c1 c2] returns the constant product of two constants floats.
- See the method [llvm::ConstantExpr::getFMul]. *)
-val const_fmul : llvalue -> llvalue -> llvalue
-
-(** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating
- point constants.
- See the method [llvm::ConstantExpr::getFDiv]. *)
-val const_fdiv : llvalue -> llvalue -> llvalue
-
-(** [const_frem c1 c2] returns the constant remainder [c1 MOD c2] of two
- signed floating point constants.
- See the method [llvm::ConstantExpr::getFRem]. *)
-val const_frem : llvalue -> llvalue -> llvalue
-
(** [const_and c1 c2] returns the constant bitwise [AND] of two integer
constants.
See the method [llvm::ConstantExpr::getAnd]. *)
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 03d964ece6064..f9fc516aa433a 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -76,6 +76,11 @@ Changes to the LLVM IR
* ``sdiv``
* ``urem``
* ``srem``
+ * ``fadd``
+ * ``fsub``
+ * ``fmul``
+ * ``fdiv``
+ * ``frem``
* Added the support for ``fmax`` and ``fmin`` in ``atomicrmw`` instruction. The
comparison is expected to match the behavior of ``llvm.maxnum.*`` and
``llvm.minnum.*`` respectively.
@@ -198,6 +203,11 @@ Changes to the C API
* ``LLVMConstExactSDiv``
* ``LLVMConstURem``
* ``LLVMConstSRem``
+ * ``LLVMConstFAdd``
+ * ``LLVMConstFSub``
+ * ``LLVMConstFMul``
+ * ``LLVMConstFDiv``
+ * ``LLVMConstFRem``
* Add ``LLVMDeleteInstruction`` function which allows deleting instructions that
are not inserted into a basic block.
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index 91c336ac21f5e..bb9e872b6ec5c 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -2167,17 +2167,12 @@ LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
-LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h
index 9ab3366b9c7b8..c50dff43dc743 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -1017,15 +1017,10 @@ class ConstantExpr : public Constant {
static Constant *getNot(Constant *C);
static Constant *getAdd(Constant *C1, Constant *C2, bool HasNUW = false,
bool HasNSW = false);
- static Constant *getFAdd(Constant *C1, Constant *C2);
static Constant *getSub(Constant *C1, Constant *C2, bool HasNUW = false,
bool HasNSW = false);
- static Constant *getFSub(Constant *C1, Constant *C2);
static Constant *getMul(Constant *C1, Constant *C2, bool HasNUW = false,
bool HasNSW = false);
- static Constant *getFMul(Constant *C1, Constant *C2);
- static Constant *getFDiv(Constant *C1, Constant *C2);
- static Constant *getFRem(Constant *C1, Constant *C2);
static Constant *getAnd(Constant *C1, Constant *C2);
static Constant *getOr(Constant *C1, Constant *C2);
static Constant *getXor(Constant *C1, Constant *C2);
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index e09da7c9169fe..030c44e27f7fa 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -3484,6 +3484,16 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
return error(ID.Loc, "urem constexprs are no longer supported");
case lltok::kw_srem:
return error(ID.Loc, "srem constexprs are no longer supported");
+ case lltok::kw_fadd:
+ return error(ID.Loc, "fadd constexprs are no longer supported");
+ case lltok::kw_fsub:
+ return error(ID.Loc, "fsub constexprs are no longer supported");
+ case lltok::kw_fmul:
+ return error(ID.Loc, "fmul constexprs are no longer supported");
+ case lltok::kw_fdiv:
+ return error(ID.Loc, "fdiv constexprs are no longer supported");
+ case lltok::kw_frem:
+ return error(ID.Loc, "frem constexprs are no longer supported");
case lltok::kw_icmp:
case lltok::kw_fcmp: {
unsigned PredVal, Opc = Lex.getUIntVal();
@@ -3543,13 +3553,8 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
}
// Binary Operators.
case lltok::kw_add:
- case lltok::kw_fadd:
case lltok::kw_sub:
- case lltok::kw_fsub:
case lltok::kw_mul:
- case lltok::kw_fmul:
- case lltok::kw_fdiv:
- case lltok::kw_frem:
case lltok::kw_shl:
case lltok::kw_lshr:
case lltok::kw_ashr: {
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 9eefd017bd280..f9800cc0c07c1 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -2355,6 +2355,11 @@ bool ConstantExpr::isSupportedBinOp(unsigned Opcode) {
case Instruction::SDiv:
case Instruction::URem:
case Instruction::SRem:
+ case Instruction::FAdd:
+ case Instruction::FSub:
+ case Instruction::FMul:
+ case Instruction::FDiv:
+ case Instruction::FRem:
return false;
case Instruction::Add:
case Instruction::Sub:
@@ -2365,11 +2370,6 @@ bool ConstantExpr::isSupportedBinOp(unsigned Opcode) {
case Instruction::And:
case Instruction::Or:
case Instruction::Xor:
- case Instruction::FAdd:
- case Instruction::FSub:
- case Instruction::FMul:
- case Instruction::FDiv:
- case Instruction::FRem:
return true;
default:
llvm_unreachable("Argument must be binop opcode");
@@ -2668,10 +2668,6 @@ Constant *ConstantExpr::getAdd(Constant *C1, Constant *C2,
return get(Instruction::Add, C1, C2, Flags);
}
-Constant *ConstantExpr::getFAdd(Constant *C1, Constant *C2) {
- return get(Instruction::FAdd, C1, C2);
-}
-
Constant *ConstantExpr::getSub(Constant *C1, Constant *C2,
bool HasNUW, bool HasNSW) {
unsigned Flags = (HasNUW ? OverflowingBinaryOperator::NoUnsignedWrap : 0) |
@@ -2679,10 +2675,6 @@ Constant *ConstantExpr::getSub(Constant *C1, Constant *C2,
return get(Instruction::Sub, C1, C2, Flags);
}
-Constant *ConstantExpr::getFSub(Constant *C1, Constant *C2) {
- return get(Instruction::FSub, C1, C2);
-}
-
Constant *ConstantExpr::getMul(Constant *C1, Constant *C2,
bool HasNUW, bool HasNSW) {
unsigned Flags = (HasNUW ? OverflowingBinaryOperator::NoUnsignedWrap : 0) |
@@ -2690,18 +2682,6 @@ Constant *ConstantExpr::getMul(Constant *C1, Constant *C2,
return get(Instruction::Mul, C1, C2, Flags);
}
-Constant *ConstantExpr::getFMul(Constant *C1, Constant *C2) {
- return get(Instruction::FMul, C1, C2);
-}
-
-Constant *ConstantExpr::getFDiv(Constant *C1, Constant *C2) {
- return get(Instruction::FDiv, C1, C2);
-}
-
-Constant *ConstantExpr::getFRem(Constant *C1, Constant *C2) {
- return get(Instruction::FRem, C1, C2);
-}
-
Constant *ConstantExpr::getAnd(Constant *C1, Constant *C2) {
return get(Instruction::And, C1, C2);
}
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 2d2bb67366708..08b7b0e1f9560 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -1574,11 +1574,6 @@ LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant,
unwrap<Constant>(RHSConstant)));
}
-LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(ConstantExpr::getFAdd(unwrap<Constant>(LHSConstant),
- unwrap<Constant>(RHSConstant)));
-}
-
LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
return wrap(ConstantExpr::getSub(unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
@@ -1596,11 +1591,6 @@ LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant,
unwrap<Constant>(RHSConstant)));
}
-LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(ConstantExpr::getFSub(unwrap<Constant>(LHSConstant),
- unwrap<Constant>(RHSConstant)));
-}
-
LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
return wrap(ConstantExpr::getMul(unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
@@ -1618,21 +1608,6 @@ LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant,
unwrap<Constant>(RHSConstant)));
}
-LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(ConstantExpr::getFMul(unwrap<Constant>(LHSConstant),
- unwrap<Constant>(RHSConstant)));
-}
-
-LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(ConstantExpr::getFDiv(unwrap<Constant>(LHSConstant),
- unwrap<Constant>(RHSConstant)));
-}
-
-LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
- return wrap(ConstantExpr::getFRem(unwrap<Constant>(LHSConstant),
- unwrap<Constant>(RHSConstant)));
-}
-
LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
return wrap(ConstantExpr::getAnd(unwrap<Constant>(LHSConstant),
unwrap<Constant>(RHSConstant)));
diff --git a/llvm/test/Bindings/OCaml/core.ml b/llvm/test/Bindings/OCaml/core.ml
index 46e84800f0c94..0bb103ac2fc3d 100644
--- a/llvm/test/Bindings/OCaml/core.ml
+++ b/llvm/test/Bindings/OCaml/core.ml
@@ -244,17 +244,12 @@ let test_constants () =
* CHECK: @const_add = global i64 add
* CHECK: @const_nsw_add = global i64 add nsw
* CHECK: @const_nuw_add = global i64 add nuw
- * CHECK: @const_fadd = global double fadd
* CHECK: @const_sub = global i64 sub
* CHECK: @const_nsw_sub = global i64 sub nsw
* CHECK: @const_nuw_sub = global i64 sub nuw
- * CHECK: @const_fsub = global double fsub
* CHECK: @const_mul = global i64 mul
* CHECK: @const_nsw_mul = global i64 mul nsw
* CHECK: @const_nuw_mul = global i64 mul nuw
- * CHECK: @const_fmul = global double fmul
- * CHECK: @const_fdiv = global double fdiv
- * CHECK: @const_frem = global double frem
* CHECK: @const_and = global i64 and
* CHECK: @const_or = global i64 or
* CHECK: @const_xor = global i64 xor
@@ -275,17 +270,12 @@ let test_constants () =
ignore (define_global "const_add" (const_add foldbomb five) m);
ignore (define_global "const_nsw_add" (const_nsw_add foldbomb five) m);
ignore (define_global "const_nuw_add" (const_nuw_add foldbomb five) m);
- ignore (define_global "const_fadd" (const_fadd ffoldbomb ffive) m);
ignore (define_global "const_sub" (const_sub foldbomb five) m);
ignore (define_global "const_nsw_sub" (const_nsw_sub foldbomb five) m);
ignore (define_global "const_nuw_sub" (const_nuw_sub foldbomb five) m);
- ignore (define_global "const_fsub" (const_fsub ffoldbomb ffive) m);
ignore (define_global "const_mul" (const_mul foldbomb five) m);
ignore (define_global "const_nsw_mul" (const_nsw_mul foldbomb five) m);
ignore (define_global "const_nuw_mul" (const_nuw_mul foldbomb five) m);
- ignore (define_global "const_fmul" (const_fmul ffoldbomb ffive) m);
- ignore (define_global "const_fdiv" (const_fdiv ffoldbomb ffive) m);
- ignore (define_global "const_frem" (const_frem ffoldbomb ffive) m);
ignore (define_global "const_and" (const_and foldbomb five) m);
ignore (define_global "const_or" (const_or foldbomb five) m);
ignore (define_global "const_xor" (const_xor foldbomb five) m);
diff --git a/llvm/test/CodeGen/AMDGPU/sched-crash-dbg-value.mir b/llvm/test/CodeGen/AMDGPU/sched-crash-dbg-value.mir
index 094f34e052a2f..c65fd0e5d01dd 100644
--- a/llvm/test/CodeGen/AMDGPU/sched-crash-dbg-value.mir
+++ b/llvm/test/CodeGen/AMDGPU/sched-crash-dbg-value.mir
@@ -124,7 +124,10 @@
%tmp93 = fmul float %tmp42, %tmp87
%tmp94 = call float @llvm.fmuladd.f32(float %tmp92, float %tmp36, float %tmp93)
%tmp95 = call float @llvm.fmuladd.f32(float %tmp48, float undef, float %tmp94)
- %tmp96 = fsub float extractelement (<2 x float> fadd (<2 x float> fmul (<2 x float> undef, <2 x float> undef), <2 x float> undef), i64 1), %tmp95
+ %fmul = fmul <2 x float> undef, undef
+ %fadd = fadd <2 x float> %fmul, undef
+ %extractelement = extractelement <2 x float> %fadd, i64 1
+ %tmp96 = fsub float %extractelement, %tmp95
%tmp97 = getelementptr inbounds %struct.wombat, %struct.wombat addrspace(5)* %tmp5, i32 0, i32 8, i32 1
call void @func(float %tmp96, i64 0, i16 addrspace(5)* nonnull %tmp97) #3
%tmp984 = bitcast [16 x i8] addrspace(3)* %17 to i8 addrspace(3)*
diff --git a/llvm/test/CodeGen/AMDGPU/si-spill-cf.ll b/llvm/test/CodeGen/AMDGPU/si-spill-cf.ll
index 153766716790c..fd9ce0c4574e7 100644
--- a/llvm/test/CodeGen/AMDGPU/si-spill-cf.ll
+++ b/llvm/test/CodeGen/AMDGPU/si-spill-cf.ll
@@ -88,7 +88,8 @@ LOOP: ; preds = %ENDIF2795, %main_bo
ENDLOOP: ; preds = %ELSE2566, %LOOP
%one.sub.a.i = fsub float 1.000000e+00, %tmp
%one.sub.ac.i = fmul float %one.sub.a.i, undef
- %result.i = fadd float fmul (float undef, float undef), %one.sub.ac.i
+ %fmul = fmul float undef, undef
+ %result.i = fadd float %fmul, %one.sub.ac.i
call void @llvm.amdgcn.exp.f32(i32 0, i32 15, float undef, float %result.i, float undef, float 1.000000e+00, i1 true, i1 true) #0
ret void
diff --git a/llvm/test/CodeGen/PowerPC/2008-07-15-Fabs.ll b/llvm/test/CodeGen/PowerPC/2008-07-15-Fabs.ll
index c30f8164cb3fa..6110602725d2d 100644
--- a/llvm/test/CodeGen/PowerPC/2008-07-15-Fabs.ll
+++ b/llvm/test/CodeGen/PowerPC/2008-07-15-Fabs.ll
@@ -8,13 +8,14 @@ target triple = "powerpc64-unknown-linux-gnu"
define hidden i256 @__divtc3(ppc_fp128 %a, ppc_fp128 %b, ppc_fp128 %c, ppc_fp128 %d) nounwind readnone {
entry:
call ppc_fp128 @fabsl( ppc_fp128 %d ) nounwind readnone ; <ppc_fp128>:0 [#uses=1]
- fcmp olt ppc_fp128 0xM00000000000000000000000000000000, %0 ; <i1>:1 [#uses=1]
+ %1 = fcmp olt ppc_fp128 0xM00000000000000000000000000000000, %0 ; <i1>:1 [#uses=1]
%.pn106 = select i1 %1, ppc_fp128 %a, ppc_fp128 0xM00000000000000000000000000000000 ; <ppc_fp128> [#uses=1]
%.pn = fsub ppc_fp128 0xM00000000000000000000000000000000, %.pn106 ; <ppc_fp128> [#uses=1]
%y.0 = fdiv ppc_fp128 %.pn, 0xM00000000000000000000000000000000 ; <ppc_fp128> [#uses=1]
- fmul ppc_fp128 %y.0, 0xM3FF00000000000000000000000000000 ; <ppc_fp128>:2 [#uses=1]
- fadd ppc_fp128 %2, fmul (ppc_fp128 0xM00000000000000000000000000000000, ppc_fp128 0xM00000000000000000000000000000000) ; <ppc_fp128>:3 [#uses=1]
- %tmpi = fadd ppc_fp128 %3, 0xM00000000000000000000000000000000 ; <ppc_fp128> [#uses=1]
+ %2 = fmul ppc_fp128 %y.0, 0xM3FF00000000000000000000000000000 ; <ppc_fp128>:2 [#uses=1]
+ %fmul = fmul ppc_fp128 0xM00000000000000000000000000000000, 0xM00000000000000000000000000000000
+ %fadd = fadd ppc_fp128 %2, %fmul
+ %tmpi = fadd ppc_fp128 %fadd, 0xM00000000000000000000000000000000
store ppc_fp128 %tmpi, ppc_fp128* null, align 16
ret i256 0
}
diff --git a/llvm/test/CodeGen/X86/2011-02-23-UnfoldBug.ll b/llvm/test/CodeGen/X86/2011-02-23-UnfoldBug.ll
index 90b90d7f9f6a0..f0da3b188b8ca 100644
--- a/llvm/test/CodeGen/X86/2011-02-23-UnfoldBug.ll
+++ b/llvm/test/CodeGen/X86/2011-02-23-UnfoldBug.ll
@@ -9,7 +9,8 @@ entry:
for.cond.outer: ; preds = %if.end71, %entry
%theta.0.ph = phi <2 x double> [ undef, %entry ], [ %theta.1, %if.end71 ]
%mul.i97 = fmul <2 x double> %theta.0.ph, undef
- %mul.i96 = fmul <2 x double> %mul.i97, fmul (<2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> undef)
+ %fmul = fmul <2 x double> <double 2.000000e+00, double 2.000000e+00>, undef
+ %mul.i96 = fmul <2 x double> %mul.i97, %fmul
br i1 undef, label %for.body, label %for.end82
for.body: ; preds = %for.cond.outer
diff --git a/llvm/test/CodeGen/X86/pr44749.ll b/llvm/test/CodeGen/X86/pr44749.ll
index 17cc431285f67..43e9a8bef410d 100644
--- a/llvm/test/CodeGen/X86/pr44749.ll
+++ b/llvm/test/CodeGen/X86/pr44749.ll
@@ -9,27 +9,29 @@ define i32 @a() {
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: ## kill: def $al killed $al killed $eax
; CHECK-NEXT: callq _b
-; CHECK-NEXT: cvtsi2sd %eax, %xmm0
+; CHECK-NEXT: cvtsi2sd %eax, %xmm1
; CHECK-NEXT: movq _calloc at GOTPCREL(%rip), %rax
; CHECK-NEXT: subq $-1, %rax
; CHECK-NEXT: setne %al
; CHECK-NEXT: movzbl %al, %eax
; CHECK-NEXT: movl %eax, %ecx
; CHECK-NEXT: leaq {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %rax
-; CHECK-NEXT: movsd {{.*#+}} xmm1 = mem[0],zero
-; CHECK-NEXT: ucomisd %xmm1, %xmm0
-; CHECK-NEXT: setae %al
-; CHECK-NEXT: movzbl %al, %eax
-; CHECK-NEXT: movl %eax, %ecx
-; CHECK-NEXT: leaq {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %rax
; CHECK-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
+; CHECK-NEXT: movsd {{.*#+}} xmm3 = mem[0],zero
+; CHECK-NEXT: movsd {{.*#+}} xmm2 = mem[0],zero
+; CHECK-NEXT: cmplesd %xmm1, %xmm0
+; CHECK-NEXT: movaps %xmm0, %xmm1
+; CHECK-NEXT: andpd %xmm3, %xmm1
+; CHECK-NEXT: andnpd %xmm2, %xmm0
+; CHECK-NEXT: orpd %xmm1, %xmm0
; CHECK-NEXT: cvttsd2si %xmm0, %eax
; CHECK-NEXT: popq %rcx
; CHECK-NEXT: retq
entry:
%call = call i32 (...) @b()
%conv = sitofp i32 %call to double
- %cmp = fcmp ole double fsub (double sitofp (i32 select (i1 icmp ne (i8* (i64, i64)* bitcast (i8* getelementptr (i8, i8* bitcast (i8* (i64, i64)* @calloc to i8*), i64 1) to i8* (i64, i64)*), i8* (i64, i64)* null), i32 1, i32 0) to double), double 1.000000e+02), %conv
+ %fsub = fsub double sitofp (i32 select (i1 icmp ne (i8* (i64, i64)* bitcast (i8* getelementptr (i8, i8* bitcast (i8* (i64, i64)* @calloc to i8*), i64 1) to i8* (i64, i64)*), i8* (i64, i64)* null), i32 1, i32 0) to double), 1.000000e+02
+ %cmp = fcmp ole double %fsub, %conv
%cond = select i1 %cmp, double 1.000000e+00, double 3.140000e+00
%conv2 = fptosi double %cond to i32
ret i32 %conv2
diff --git a/llvm/test/DebugInfo/ARM/selectiondag-deadcode.ll b/llvm/test/DebugInfo/ARM/selectiondag-deadcode.ll
index 5246575efd1df..ca0cb3486dd78 100644
--- a/llvm/test/DebugInfo/ARM/selectiondag-deadcode.ll
+++ b/llvm/test/DebugInfo/ARM/selectiondag-deadcode.ll
@@ -2,7 +2,11 @@
target triple = "thumbv7-apple-ios7.0.0"
%class.Matrix3.0.6.10 = type { [9 x float] }
define arm_aapcscc void @_Z9GetMatrixv(%class.Matrix3.0.6.10* noalias nocapture sret(%class.Matrix3.0.6.10) %agg.result) #0 !dbg !39 {
- br i1 fcmp oeq (float fadd (float fadd (float fmul (float undef, float undef), float fmul (float undef, float undef)), float fmul (float undef, float undef)), float 0.000000e+00), label %_ZN7Vector39NormalizeEv.exit, label %1
+ %fmul = fmul float undef, undef
+ %fadd = fadd float %fmul, %fmul
+ %fadd2 = fadd float %fadd, %fmul
+ %fcmp = fcmp oeq float %fadd2, 0.000000e+00
+ br i1 %fcmp, label %_ZN7Vector39NormalizeEv.exit, label %1
tail call arm_aapcscc void @_ZL4Sqrtd() #3
br label %_ZN7Vector39NormalizeEv.exit
_ZN7Vector39NormalizeEv.exit: ; preds = %1, %0
diff --git a/llvm/test/Transforms/InstCombine/fma.ll b/llvm/test/Transforms/InstCombine/fma.ll
index 82fffd16ef521..06fb767c99537 100644
--- a/llvm/test/Transforms/InstCombine/fma.ll
+++ b/llvm/test/Transforms/InstCombine/fma.ll
@@ -99,7 +99,8 @@ define float @fma_fneg_const_fneg_y(float %y, float %z) {
; CHECK-NEXT: ret float [[FMA]]
;
%y.fneg = fsub float -0.0, %y
- %fma = call float @llvm.fma.f32(float fsub (float -0.0, float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %y.fneg, float %z)
+ %fsub = fsub float -0.0, bitcast (i32 ptrtoint (i32* @external to i32) to float)
+ %fma = call float @llvm.fma.f32(float %fsub, float %y.fneg, float %z)
ret float %fma
}
@@ -119,7 +120,8 @@ define float @fma_fneg_x_fneg_const(float %x, float %z) {
; CHECK-NEXT: ret float [[FMA]]
;
%x.fneg = fsub float -0.0, %x
- %fma = call float @llvm.fma.f32(float %x.fneg, float fsub (float -0.0, float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %z)
+ %fsub = fsub float -0.0, bitcast (i32 ptrtoint (i32* @external to i32) to float)
+ %fma = call float @llvm.fma.f32(float %x.fneg, float %fsub, float %z)
ret float %fma
}
@@ -218,7 +220,8 @@ define float @fmuladd_fneg_const_fneg_y(float %y, float %z) {
; CHECK-NEXT: ret float [[FMULADD]]
;
%y.fneg = fsub float -0.0, %y
- %fmuladd = call float @llvm.fmuladd.f32(float fsub (float -0.0, float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %y.fneg, float %z)
+ %fsub = fsub float -0.0, bitcast (i32 ptrtoint (i32* @external to i32) to float)
+ %fmuladd = call float @llvm.fmuladd.f32(float %fsub, float %y.fneg, float %z)
ret float %fmuladd
}
@@ -238,7 +241,8 @@ define float @fmuladd_fneg_x_fneg_const(float %x, float %z) {
; CHECK-NEXT: ret float [[FMULADD]]
;
%x.fneg = fsub float -0.0, %x
- %fmuladd = call float @llvm.fmuladd.f32(float %x.fneg, float fsub (float -0.0, float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %z)
+ %fsub = fsub float -0.0, bitcast (i32 ptrtoint (i32* @external to i32) to float)
+ %fmuladd = call float @llvm.fmuladd.f32(float %x.fneg, float %fsub, float %z)
ret float %fmuladd
}
diff --git a/llvm/test/Transforms/InstCombine/fmul.ll b/llvm/test/Transforms/InstCombine/fmul.ll
index 33e304fb00f89..10c8bdd532817 100644
--- a/llvm/test/Transforms/InstCombine/fmul.ll
+++ b/llvm/test/Transforms/InstCombine/fmul.ll
@@ -1057,10 +1057,11 @@ define float @fmul_fdiv_factor_extra_use(float %x, float %y) {
define double @fmul_negated_constant_expression(double %x) {
; CHECK-LABEL: @fmul_negated_constant_expression(
-; CHECK-NEXT: [[R:%.*]] = fmul double [[X:%.*]], fsub (double -0.000000e+00, double bitcast (i64 ptrtoint (i8** getelementptr inbounds ({ [2 x i8*] }, { [2 x i8*] }* @g, i64 0, inrange i32 0, i64 2) to i64) to double))
+; CHECK-NEXT: [[R:%.*]] = fmul double [[X:%.*]], fneg (double bitcast (i64 ptrtoint (i8** getelementptr inbounds ({ [2 x i8*] }, { [2 x i8*] }* @g, i64 0, inrange i32 0, i64 2) to i64) to double))
; CHECK-NEXT: ret double [[R]]
;
- %r = fmul double %x, fsub (double -0.000000e+00, double bitcast (i64 ptrtoint (i8** getelementptr inbounds ({ [2 x i8*] }, { [2 x i8*] }* @g, i64 0, inrange i32 0, i64 2) to i64) to double))
+ %fsub = fsub double -0.000000e+00, bitcast (i64 ptrtoint (i8** getelementptr inbounds ({ [2 x i8*] }, { [2 x i8*] }* @g, i64 0, inrange i32 0, i64 2) to i64) to double)
+ %r = fmul double %x, %fsub
ret double %r
}
diff --git a/llvm/test/Transforms/InstSimplify/ConstProp/bitcast.ll b/llvm/test/Transforms/InstSimplify/ConstProp/bitcast.ll
index 05160b9ad72ab..99b1eb6ef07d3 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/bitcast.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/bitcast.ll
@@ -17,9 +17,14 @@ define <1 x i64> @test1() {
define i1 @bad_icmp_constexpr_bitcast() {
; CHECK-LABEL: @bad_icmp_constexpr_bitcast(
-; CHECK-NEXT: ret i1 icmp eq (i32 ptrtoint (ptr @a to i32), i32 bitcast (float fadd (float bitcast (i32 ptrtoint (ptr @b to i32) to float), float 2.000000e+00) to i32))
+; CHECK-NEXT: [[FADD:%.*]] = fadd float bitcast (i32 ptrtoint (ptr @b to i32) to float), 2.000000e+00
+; CHECK-NEXT: [[BITCAST:%.*]] = bitcast float [[FADD]] to i32
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 ptrtoint (ptr @a to i32), [[BITCAST]]
+; CHECK-NEXT: ret i1 [[CMP]]
;
- %cmp = icmp eq i32 ptrtoint (ptr @a to i32), bitcast (float fadd (float bitcast (i32 ptrtoint (ptr @b to i32) to float), float 2.0) to i32)
+ %fadd = fadd float bitcast (i32 ptrtoint (ptr @b to i32) to float), 2.0
+ %bitcast = bitcast float %fadd to i32
+ %cmp = icmp eq i32 ptrtoint (ptr @a to i32), %bitcast
ret i1 %cmp
}
diff --git a/llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll b/llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll
index 04a8f7c62ebb6..8978d9200afb6 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll
@@ -51,13 +51,6 @@
@T5 = global ptr inttoptr (i64 add (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (ptr @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (ptr @A to i64) to i256), i256 192)), i256 192) to i64), i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (ptr @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (ptr @A to i64) to i256), i256 192)), i256 128) to i64)) to ptr)
-
-; PR6096
-
-; No check line. This used to crash llvm-as.
- at T6 = global <2 x i1> fcmp ole (<2 x float> fdiv (<2 x float> undef, <2 x float> <float 1.000000e+00, float 1.000000e+00>), <2 x float> zeroinitializer)
-
-
; PR9011
@pr9011_1 = constant <4 x i32> zext (<4 x i8> zeroinitializer to <4 x i32>)
diff --git a/llvm/test/Transforms/InstSimplify/fdiv.ll b/llvm/test/Transforms/InstSimplify/fdiv.ll
index 046a07ce90c22..2b998b3e73234 100644
--- a/llvm/test/Transforms/InstSimplify/fdiv.ll
+++ b/llvm/test/Transforms/InstSimplify/fdiv.ll
@@ -50,3 +50,12 @@ define <2 x float> @fmul_fdiv_common_operand_commute_vec(<2 x float> %x, <2 x fl
ret <2 x float> %d
}
+; The constant expression version of this used to crash llvm-as.
+define <2 x i1> @pr6096() {
+; CHECK-LABEL: @pr6096(
+; CHECK-NEXT: ret <2 x i1> zeroinitializer
+;
+ %fdiv = fdiv <2 x float> undef, <float 1.000000e+00, float 1.000000e+00>
+ %fcmp = fcmp ole <2 x float> %fdiv, zeroinitializer
+ ret <2 x i1> %fcmp
+}
diff --git a/llvm/test/Transforms/LoopVectorize/scev-exitlim-crash.ll b/llvm/test/Transforms/LoopVectorize/scev-exitlim-crash.ll
index 324dbfc5ee49f..6a07af9bdf8f1 100644
--- a/llvm/test/Transforms/LoopVectorize/scev-exitlim-crash.ll
+++ b/llvm/test/Transforms/LoopVectorize/scev-exitlim-crash.ll
@@ -18,7 +18,9 @@ entry:
for.cond: ; preds = %for.cond, %entry
%i.0 = phi i32 [ undef, %entry ], [ %inc, %for.cond ]
%cmp = icmp slt i32 %i.0, 0
- %call = tail call i32 @fn2(double fadd (double fsub (double undef, double undef), double 1.000000e+00)) #2
+ %fsub = fsub double undef, undef
+ %fadd = fadd double %fsub, 1.000000e+00
+ %call = tail call i32 @fn2(double %fadd) #2
%inc = add nsw i32 %i.0, 1
br i1 %cmp, label %for.cond, label %for.cond4.preheader
diff --git a/llvm/unittests/IR/ConstantsTest.cpp b/llvm/unittests/IR/ConstantsTest.cpp
index 24dc2b3975858..dce63a54b06ee 100644
--- a/llvm/unittests/IR/ConstantsTest.cpp
+++ b/llvm/unittests/IR/ConstantsTest.cpp
@@ -248,13 +248,8 @@ TEST(ConstantsTest, AsInstructionsTest) {
"add nsw i32 " P0STR ", " P0STR);
CHECK(ConstantExpr::getAdd(P0, P0, true, true),
"add nuw nsw i32 " P0STR ", " P0STR);
- CHECK(ConstantExpr::getFAdd(P1, P1), "fadd float " P1STR ", " P1STR);
CHECK(ConstantExpr::getSub(P0, P0), "sub i32 " P0STR ", " P0STR);
- CHECK(ConstantExpr::getFSub(P1, P1), "fsub float " P1STR ", " P1STR);
CHECK(ConstantExpr::getMul(P0, P0), "mul i32 " P0STR ", " P0STR);
- CHECK(ConstantExpr::getFMul(P1, P1), "fmul float " P1STR ", " P1STR);
- CHECK(ConstantExpr::getFDiv(P1, P1), "fdiv float " P1STR ", " P1STR);
- CHECK(ConstantExpr::getFRem(P1, P1), "frem float " P1STR ", " P1STR);
CHECK(ConstantExpr::getAnd(P0, P0), "and i32 " P0STR ", " P0STR);
CHECK(ConstantExpr::getOr(P0, P0), "or i32 " P0STR ", " P0STR);
CHECK(ConstantExpr::getXor(P0, P0), "xor i32 " P0STR ", " P0STR);
More information about the llvm-commits
mailing list