===================================================================
@@ -12112,9 +12112,22 @@
(set (match_operand:SWI48 0 "register_operand" "=r")
(ctz:SWI48 (match_dup 1)))]
""
- "bsf{<imodesuffix>}\t{%1, %0|%0, %1}"
+{
+ if (optimize_function_for_size_p (cfun))
+ return "bsf{<imodesuffix>}\t{%1, %0|%0, %1}";
+ else if (TARGET_BMI)
+ return "tzcnt{<imodesuffix>}\t{%1, %0|%0, %1}";
+ else
+ /* tzcnt expands to rep;bsf and we can use it even if !TARGET_BMI. */
+ return "rep; bsf{<imodesuffix>}\t{%1, %0|%0, %1}";
+}
[(set_attr "type" "alu1")
(set_attr "prefix_0f" "1")
+ (set (attr "prefix_rep")
+ (if_then_else
+ (match_test "optimize_function_for_size_p (cfun)")
+ (const_string "0")
+ (const_string "1")))
(set_attr "mode" "<MODE>")])
(define_insn "ctz<mode>2"
@@ -12123,14 +12136,21 @@
(clobber (reg:CC FLAGS_REG))]
""
{
- if (TARGET_BMI)
+ if (optimize_function_for_size_p (cfun))
+ return "bsf{<imodesuffix>}\t{%1, %0|%0, %1}";
+ else if (TARGET_BMI)
return "tzcnt{<imodesuffix>}\t{%1, %0|%0, %1}";
- else
- return "bsf{<imodesuffix>}\t{%1, %0|%0, %1}";
+ else
+ /* tzcnt expands to rep;bsf and we can use it even if !TARGET_BMI. */
+ return "rep; bsf{<imodesuffix>}\t{%1, %0|%0, %1}";
}
[(set_attr "type" "alu1")
(set_attr "prefix_0f" "1")
- (set (attr "prefix_rep") (symbol_ref "TARGET_BMI"))
+ (set (attr "prefix_rep")
+ (if_then_else
+ (match_test "optimize_function_for_size_p (cfun)")
+ (const_string "0")
+ (const_string "1")))
(set_attr "mode" "<MODE>")])
(define_expand "clz<mode>2"