File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -1344,15 +1344,18 @@ def : Pat<(i32 (anyext_sdiv GR8:$src)), (MOVSX32rr8 GR8:$src)>;
1344
1344
1345
1345
// Any instruction that defines a 32-bit result leaves the high half of the
1346
1346
// register. Truncate can be lowered to EXTRACT_SUBREG. CopyFromReg may
1347
- // be copying from a truncate. Any other 32-bit operation will zero-extend
1348
- // up to 64 bits. AssertSext/AssertZext aren't saying anything about the upper
1349
- // 32 bits, they're probably just qualifying a CopyFromReg.
1347
+ // be copying from a truncate. AssertSext/AssertZext/AssertAlign aren't saying
1348
+ // anything about the upper 32 bits, they're probably just qualifying a
1349
+ // CopyFromReg. FREEZE may be coming from a a truncate. Any other 32-bit
1350
+ // operation will zero-extend up to 64 bits.
1350
1351
def def32 : PatLeaf<(i32 GR32:$src), [{
1351
1352
return N->getOpcode() != ISD::TRUNCATE &&
1352
1353
N->getOpcode() != TargetOpcode::EXTRACT_SUBREG &&
1353
1354
N->getOpcode() != ISD::CopyFromReg &&
1354
1355
N->getOpcode() != ISD::AssertSext &&
1355
- N->getOpcode() != ISD::AssertZext;
1356
+ N->getOpcode() != ISD::AssertZext &&
1357
+ N->getOpcode() != ISD::AssertAlign &&
1358
+ N->getOpcode() != ISD::FREEZE;
1356
1359
}]>;
1357
1360
1358
1361
// In the case of a 32-bit def that is known to implicitly zero-extend,
Original file line number Diff line number Diff line change @@ -122,3 +122,26 @@ define i64 @freeze_array() {
122
122
%t1 = add i64 %v1 , %v2
123
123
ret i64 %t1
124
124
}
125
+
126
+ ; Make sure we emit a movl to zext the input before the imulq. This previously
127
+ ; failed because freeze was not listed in the instructions that don't zext their
128
+ ; result in the def32 pattern X86InstrCompiler.td.
129
+ define i32 @freeze_zext (i64 %a ) nounwind {
130
+ ; X86ASM-LABEL: freeze_zext:
131
+ ; X86ASM: # %bb.0: # %entry
132
+ ; X86ASM-NEXT: movq %rdi, %rax
133
+ ; X86ASM-NEXT: movl %eax, %ecx
134
+ ; X86ASM-NEXT: movl $3435973837, %edx # imm = 0xCCCCCCCD
135
+ ; X86ASM-NEXT: imulq %rcx, %rdx
136
+ ; X86ASM-NEXT: shrq $35, %rdx
137
+ ; X86ASM-NEXT: addl %edx, %edx
138
+ ; X86ASM-NEXT: leal (%rdx,%rdx,4), %ecx
139
+ ; X86ASM-NEXT: subl %ecx, %eax
140
+ ; X86ASM-NEXT: # kill: def $eax killed $eax killed $rax
141
+ ; X86ASM-NEXT: retq
142
+ entry:
143
+ %x = trunc i64 %a to i32
144
+ %y = freeze i32 %x
145
+ %z = urem i32 %y , 10
146
+ ret i32 %z
147
+ }
You can’t perform that action at this time.
0 commit comments