-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[IR] Add support for samesign
in Operator::hasPoisonGeneratingFlags
#112358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-llvm-transforms Author: Yingwei Zheng (dtcxzyw) ChangesFix #112356. Sorry about that... Full diff: https://github.com/llvm/llvm-project/pull/112358.diff 2 Files Affected:
diff --git a/llvm/lib/IR/Operator.cpp b/llvm/lib/IR/Operator.cpp
index f93ff8f6fc8a25..199eb4d90f5565 100644
--- a/llvm/lib/IR/Operator.cpp
+++ b/llvm/lib/IR/Operator.cpp
@@ -50,6 +50,8 @@ bool Operator::hasPoisonGeneratingFlags() const {
if (auto *NNI = dyn_cast<PossiblyNonNegInst>(this))
return NNI->hasNonNeg();
return false;
+ case Instruction::ICmp:
+ return cast<ICmpInst>(this)->hasSameSign();
default:
if (const auto *FP = dyn_cast<FPMathOperator>(this))
return FP->hasNoNaNs() || FP->hasNoInfs();
diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll
index ecf21b8a42cf50..bfe70f992b8457 100644
--- a/llvm/test/Transforms/InstCombine/icmp.ll
+++ b/llvm/test/Transforms/InstCombine/icmp.ll
@@ -5365,3 +5365,14 @@ define i1 @icmp_and_inv_pow2_or_zero_ne_0(i32 %A, i32 %B) {
%cmp = icmp ne i32 %and, 0
ret i1 %cmp
}
+
+define i1 @icmp_samesign_logical_and(i32 %In) {
+; CHECK-LABEL: @icmp_samesign_logical_and(
+; CHECK-NEXT: [[C2:%.*]] = icmp eq i32 [[IN:%.*]], 1
+; CHECK-NEXT: ret i1 [[C2]]
+;
+ %c1 = icmp samesign sgt i32 %In, -1
+ %c2 = icmp samesign eq i32 %In, 1
+ %V = select i1 %c1, i1 %c2, i1 false
+ ret i1 %V
+}
|
Oh, thank you very much for this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fix #112356. Sorry about that...