[llvm] 8edb9c3 - [ConstantExpr] Don't create float binop expressions
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 8 07:53:56 PDT 2022
Author: Nikita Popov
Date: 2022-07-08T16:53:46+02:00
New Revision: 8edb9c3c56e88e38d82582e5fc96befca3d6223c
URL: https://github.com/llvm/llvm-project/commit/8edb9c3c56e88e38d82582e5fc96befca3d6223c
DIFF: https://github.com/llvm/llvm-project/commit/8edb9c3c56e88e38d82582e5fc96befca3d6223c.diff
LOG: [ConstantExpr] Don't create float binop expressions
Mark the fadd, fsub, fmul, fdiv, and frem expressions as
undesirable, so they are not created automatically. This is in
preparation for their removal.
Added:
Modified:
llvm/lib/IR/Constants.cpp
llvm/test/Transforms/Reassociate/crash2.ll
Removed:
################################################################################
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 650b076f8d168..9eefd017bd280 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -2328,6 +2328,11 @@ bool ConstantExpr::isDesirableBinOp(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:
@@ -2338,11 +2343,6 @@ bool ConstantExpr::isDesirableBinOp(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");
diff --git a/llvm/test/Transforms/Reassociate/crash2.ll b/llvm/test/Transforms/Reassociate/crash2.ll
index 0da5bde2b31d0..f45fbefcd3992 100644
--- a/llvm/test/Transforms/Reassociate/crash2.ll
+++ b/llvm/test/Transforms/Reassociate/crash2.ll
@@ -7,7 +7,7 @@
define float @undef1() {
; CHECK-LABEL: @undef1(
-; CHECK-NEXT: ret float fadd (float bitcast (i32 ptrtoint (i32* @g to i32) to float), float fadd (float bitcast (i32 ptrtoint (i32* @g to i32) to float), float fadd (float fneg (float bitcast (i32 ptrtoint (i32* @g to i32) to float)), float fneg (float bitcast (i32 ptrtoint (i32* @g to i32) to float)))))
+; CHECK-NEXT: ret float 0.000000e+00
;
%t0 = fadd fast float bitcast (i32 ptrtoint (i32* @g to i32) to float), bitcast (i32 ptrtoint (i32* @g to i32) to float)
%t1 = fsub fast float bitcast (i32 ptrtoint (i32* @g to i32) to float), %t0
More information about the llvm-commits
mailing list