[llvm] r339938 - add a missed case for binary op FMF propagation under select folds
Michael Berg via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 16 13:59:46 PDT 2018
Author: mcberg2017
Date: Thu Aug 16 13:59:45 2018
New Revision: 339938
URL: http://llvm.org/viewvc/llvm-project?rev=339938&view=rev
Log:
add a missed case for binary op FMF propagation under select folds
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/trunk/test/Transforms/InstCombine/select_meta.ll
llvm/trunk/test/Transforms/LoopVectorize/reduction.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp?rev=339938&r1=339937&r2=339938&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp Thu Aug 16 13:59:45 2018
@@ -354,7 +354,9 @@ Instruction *InstCombiner::foldSelectOpO
Value *Op0 = MatchIsOpZero ? MatchOp : NewSI;
Value *Op1 = MatchIsOpZero ? NewSI : MatchOp;
if (auto *BO = dyn_cast<BinaryOperator>(TI)) {
- return BinaryOperator::Create(BO->getOpcode(), Op0, Op1);
+ BinaryOperator *NewBO = BinaryOperator::Create(BO->getOpcode(), Op0, Op1);
+ NewBO->copyIRFlags(BO);
+ return NewBO;
}
if (auto *TGEP = dyn_cast<GetElementPtrInst>(TI)) {
auto *FGEP = cast<GetElementPtrInst>(FI);
Modified: llvm/trunk/test/Transforms/InstCombine/select_meta.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/select_meta.ll?rev=339938&r1=339937&r2=339938&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/select_meta.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/select_meta.ll Thu Aug 16 13:59:45 2018
@@ -7,7 +7,7 @@ define i32 @foo(i32) local_unnamed_addr
; CHECK-LABEL: @foo(
; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 %0, 2
; CHECK-NEXT: [[DOTV:%.*]] = select i1 [[TMP2]], i32 20, i32 -20, !prof ![[$MD1:[0-9]+]]
-; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[DOTV]], %0
+; CHECK-NEXT: [[TMP3:%.*]] = add nsw i32 [[DOTV]], %0
; CHECK-NEXT: ret i32 [[TMP3]]
;
%2 = icmp sgt i32 %0, 2
Modified: llvm/trunk/test/Transforms/LoopVectorize/reduction.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopVectorize/reduction.ll?rev=339938&r1=339937&r2=339938&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopVectorize/reduction.ll (original)
+++ llvm/trunk/test/Transforms/LoopVectorize/reduction.ll Thu Aug 16 13:59:45 2018
@@ -325,7 +325,7 @@ for.end:
; We can vectorize conditional reductions with multi-input phis.
; CHECK: reduction_conditional
-; CHECK: fadd <4 x float>
+; CHECK: fadd fast <4 x float>
define float @reduction_conditional(float* %A, float* %B, float* %C, float %S) {
entry:
More information about the llvm-commits
mailing list