Skip to content

Commit 407b63b

Browse files
author
badumbatish
committed
[InstCombine] Fold poison pow to poison
1 parent b0b5b31 commit 407b63b

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
@@ -47,18 +47,12 @@ define void @powi_i16(float %V, ptr%P) {
4747

4848
define void @pow_poison_i16(i16 %arg_int,float %arg_flt, ptr %P) {
4949
; CHECK-LABEL: @pow_poison_i16(
50-
; CHECK-NEXT: [[TMP1:%.*]] = tail call float @llvm.powi.f32.i16(float poison, i16 [[ARG_INT:%.*]]) #[[ATTR1:[0-9]+]]
51-
; CHECK-NEXT: store volatile float [[TMP1]], ptr [[P:%.*]], align 4
52-
; CHECK-NEXT: [[TMP2:%.*]] = tail call float @llvm.pow.f32(float poison, float [[ARG_FLT:%.*]]) #[[ATTR1]]
53-
; CHECK-NEXT: store volatile float [[TMP2]], ptr [[P]], align 4
54-
; CHECK-NEXT: [[TMP3:%.*]] = tail call float @llvm.powi.f32.i16(float [[ARG_FLT]], i16 poison) #[[ATTR1]]
55-
; CHECK-NEXT: store volatile float [[TMP3]], ptr [[P]], align 4
56-
; CHECK-NEXT: [[TMP4:%.*]] = tail call float @llvm.pow.f32(float [[ARG_FLT]], float poison) #[[ATTR1]]
57-
; CHECK-NEXT: store volatile float [[TMP4]], ptr [[P]], align 4
58-
; CHECK-NEXT: [[TMP5:%.*]] = tail call float @llvm.powi.f32.i16(float poison, i16 poison) #[[ATTR1]]
59-
; CHECK-NEXT: store volatile float [[TMP5]], ptr [[P]], align 4
60-
; CHECK-NEXT: [[TMP6:%.*]] = tail call float @llvm.pow.f32(float poison, float poison) #[[ATTR1]]
61-
; CHECK-NEXT: store volatile float [[TMP6]], ptr [[P]], align 4
50+
; CHECK-NEXT: store volatile float poison, ptr [[P:%.*]], align 4
51+
; CHECK-NEXT: store volatile float poison, ptr [[P]], align 4
52+
; CHECK-NEXT: store volatile float poison, ptr [[P]], align 4
53+
; CHECK-NEXT: store volatile float poison, ptr [[P]], align 4
54+
; CHECK-NEXT: store volatile float poison, ptr [[P]], align 4
55+
; CHECK-NEXT: store volatile float poison, ptr [[P]], align 4
6256
; CHECK-NEXT: ret void
6357
;
6458
%2 = tail call float @llvm.powi.f32.i16(float poison, i16 %arg_int) nounwind

0 commit comments

Comments
 (0)