File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
lib/Transforms/InstCombine
test/Transforms/InstCombine Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -300,9 +300,8 @@ Instruction *InstCombinerImpl::visitMul(BinaryOperator &I) {
300
300
// Canonicalize (X|C1)*MulC -> X*MulC+C1*MulC.
301
301
Value *X;
302
302
Constant *C1;
303
- if ((match (Op0, m_OneUse (m_Add (m_Value (X), m_ImmConstant (C1))))) ||
304
- (match (Op0, m_OneUse (m_Or (m_Value (X), m_ImmConstant (C1)))) &&
305
- haveNoCommonBitsSet (X, C1, SQ.getWithInstruction (&I)))) {
303
+ if (match (Op0, m_OneUse (m_Add (m_Value (X), m_ImmConstant (C1)))) ||
304
+ match (Op0, m_OneUse (m_DisjointOr (m_Value (X), m_ImmConstant (C1))))) {
306
305
// C1*MulC simplifies to a tidier constant.
307
306
Value *NewC = Builder.CreateMul (C1, MulC);
308
307
auto *BOp0 = cast<BinaryOperator>(Op0);
Original file line number Diff line number Diff line change @@ -964,6 +964,28 @@ define i32 @PR57278_mul_assume(i32 %a) {
964
964
965
965
declare void @llvm.assume (i1 )
966
966
967
+ define i32 @PR57278_or_disjoint_nuw (i32 %a ) {
968
+ ; CHECK-LABEL: @PR57278_or_disjoint_nuw(
969
+ ; CHECK-NEXT: [[TMP1:%.*]] = mul nuw i32 [[A:%.*]], 3
970
+ ; CHECK-NEXT: [[MUL:%.*]] = add nuw i32 [[TMP1]], 9
971
+ ; CHECK-NEXT: ret i32 [[MUL]]
972
+ ;
973
+ %add = or disjoint i32 %a , 3
974
+ %mul = mul nuw i32 %add , 3
975
+ ret i32 %mul
976
+ }
977
+
978
+ define i32 @PR57278_or_disjoint_nsw (i32 %a ) {
979
+ ; CHECK-LABEL: @PR57278_or_disjoint_nsw(
980
+ ; CHECK-NEXT: [[TMP1:%.*]] = mul i32 [[A:%.*]], 3
981
+ ; CHECK-NEXT: [[MUL:%.*]] = add i32 [[TMP1]], 9
982
+ ; CHECK-NEXT: ret i32 [[MUL]]
983
+ ;
984
+ %add = or disjoint i32 %a , 3
985
+ %mul = mul nsw i32 %add , 3
986
+ ret i32 %mul
987
+ }
988
+
967
989
; https://alive2.llvm.org/ce/z/XYpv9q
968
990
define <2 x i32 > @PR57278_shl_vec (<2 x i32 > %v1 ) {
969
991
; CHECK-LABEL: @PR57278_shl_vec(
You can’t perform that action at this time.
0 commit comments