Skip to content

Commit 6abd9cd

Browse files
author
badumbatish
committed
[InstCombine] Fold poison pow to poison
1 parent 676fdaa commit 6abd9cd

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6673,7 +6673,13 @@ Value *llvm::simplifyBinaryIntrinsic(Intrinsic::ID IID, Type *ReturnType,
66736673
if (auto *C1 = dyn_cast<Constant>(Op1))
66746674
return simplifyRelativeLoad(C0, C1, Q.DL);
66756675
break;
6676+
case Intrinsic::pow:
6677+
if (isa<PoisonValue>(Op0) || isa<PoisonValue>(Op1))
6678+
return PoisonValue::get(ReturnType);
6679+
break;
66766680
case Intrinsic::powi:
6681+
if (isa<PoisonValue>(Op0) || isa<PoisonValue>(Op1))
6682+
return PoisonValue::get(ReturnType);
66776683
if (auto *Power = dyn_cast<ConstantInt>(Op1)) {
66786684
// powi(x, 0) -> 1.0
66796685
if (Power->isZero())

llvm/test/Transforms/InstSimplify/fold-intrinsics.ll

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,12 @@ define i32 @test_ctpop_poison(i32 %a) {
5555

5656
define void @pow_poison_i16(i16 %arg_int,float %arg_flt, ptr %P) {
5757
; CHECK-LABEL: @pow_poison_i16(
58-
; CHECK-NEXT: [[TMP1:%.*]] = tail call float @llvm.powi.f32.i16(float poison, i16 [[ARG_INT:%.*]]) #[[ATTR1:[0-9]+]]
59-
; CHECK-NEXT: store volatile float [[TMP1]], ptr [[P:%.*]], align 4
60-
; CHECK-NEXT: [[TMP2:%.*]] = tail call float @llvm.pow.f32(float poison, float [[ARG_FLT:%.*]]) #[[ATTR1]]
61-
; CHECK-NEXT: store volatile float [[TMP2]], ptr [[P]], align 4
62-
; CHECK-NEXT: [[TMP3:%.*]] = tail call float @llvm.powi.f32.i16(float [[ARG_FLT]], i16 poison) #[[ATTR1]]
63-
; CHECK-NEXT: store volatile float [[TMP3]], ptr [[P]], align 4
64-
; CHECK-NEXT: [[TMP4:%.*]] = tail call float @llvm.pow.f32(float [[ARG_FLT]], float poison) #[[ATTR1]]
65-
; CHECK-NEXT: store volatile float [[TMP4]], ptr [[P]], align 4
66-
; CHECK-NEXT: [[TMP5:%.*]] = tail call float @llvm.powi.f32.i16(float poison, i16 poison) #[[ATTR1]]
67-
; CHECK-NEXT: store volatile float [[TMP5]], ptr [[P]], align 4
68-
; CHECK-NEXT: [[TMP6:%.*]] = tail call float @llvm.pow.f32(float poison, float poison) #[[ATTR1]]
69-
; CHECK-NEXT: store volatile float [[TMP6]], ptr [[P]], align 4
58+
; CHECK-NEXT: store volatile float poison, ptr [[P:%.*]], align 4
59+
; CHECK-NEXT: store volatile float poison, ptr [[P]], align 4
60+
; CHECK-NEXT: store volatile float poison, ptr [[P]], align 4
61+
; CHECK-NEXT: store volatile float poison, ptr [[P]], align 4
62+
; CHECK-NEXT: store volatile float poison, ptr [[P]], align 4
63+
; CHECK-NEXT: store volatile float poison, ptr [[P]], align 4
7064
; CHECK-NEXT: ret void
7165
;
7266
%2 = tail call float @llvm.powi.f32.i16(float poison, i16 %arg_int) nounwind

0 commit comments

Comments
 (0)