File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
test/Transforms/Reassociate Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -2256,9 +2256,10 @@ void ReassociatePass::OptimizeInst(Instruction *I) {
2256
2256
// with no common bits set, convert it to X+Y.
2257
2257
if (I->getOpcode () == Instruction::Or &&
2258
2258
shouldConvertOrWithNoCommonBitsToAdd (I) && !isLoadCombineCandidate (I) &&
2259
- haveNoCommonBitsSet (I->getOperand (0 ), I->getOperand (1 ),
2260
- SimplifyQuery (I->getModule ()->getDataLayout (),
2261
- /* DT=*/ nullptr , /* AC=*/ nullptr , I))) {
2259
+ (I->isDisjoint () ||
2260
+ haveNoCommonBitsSet (I->getOperand (0 ), I->getOperand (1 ),
2261
+ SimplifyQuery (I->getModule ()->getDataLayout (),
2262
+ /* DT=*/ nullptr , /* AC=*/ nullptr , I)))) {
2262
2263
Instruction *NI = convertOrWithNoCommonBitsToAdd (I);
2263
2264
RedoInsts.insert (I);
2264
2265
MadeChange = true ;
Original file line number Diff line number Diff line change @@ -59,6 +59,18 @@ define i32 @test3(i32 %x, i32 %bit) {
59
59
ret i32 %res
60
60
}
61
61
62
+ ; Test that disjoint allow reassociation.
63
+ define i32 @test4 (i32 %a , i32 %b ) {
64
+ ; CHECK-LABEL: @test4(
65
+ ; CHECK-NEXT: [[C:%.*]] = add i32 [[A:%.*]], 1
66
+ ; CHECK-NEXT: [[C_PLUS_ONE:%.*]] = add i32 [[C]], [[B:%.*]]
67
+ ; CHECK-NEXT: ret i32 [[C_PLUS_ONE]]
68
+ ;
69
+ %c = or disjoint i32 %a , %b
70
+ %c.plus.one = add i32 %c , 1
71
+ ret i32 %c.plus.one
72
+ }
73
+
62
74
declare i32 @llvm.ctlz.i32 (i32 , i1 immarg) #2
63
75
64
76
!0 = !{i32 0 , i32 33 }
You can’t perform that action at this time.
0 commit comments